转载:linux+arm 网卡故障调试:ethtool&phy寄存器读写
来源:互联网 发布:mac book air能吃鸡吗 编辑:程序博客网 时间:2024/06/03 15:58
两个工具一个是ethtool工具,一个是源码编译的可以读phy寄存器的工具phyreg。两者结合使用,事半功倍。
ethtool 可以查看和设置网卡的工作状态,比如查看设置网卡的链接 自协商,10/100/1000M,双工半双工的工作状态。
ethtool的交叉编译工具,见个人博客文章:http://blog.csdn.net/vc66vcc/article/details/52398864
phyreg 可以读写phy的任意寄存器。相关源码如下
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <linux/mii.h>
- #include <sys/types.h>
- #include <sys/socket.h>
- #include <sys/ioctl.h>
- #include <net/if.h>
- #include <linux/sockios.h>
- #include <linux/types.h>
- #include <netinet/in.h>
- #define reteck(ret) \
- if(ret < 0){ \
- printf(”%m! \”%s\” : line: %d\n”, func, LINE); \
- goto lab; \
- }
- #define help() \
- printf(”mdio:\n”); \
- printf(”read operation: mdio reg_addr\n”); \
- printf(”write operation: mdio reg_addr value\n”); \
- printf(”For example:\n”); \
- printf(”mdio eth0 1\n”); \
- printf(”mdio eth0 0 0x12\n\n”); \
- exit(0);
- int sockfd;
- int main(int argc, char argv[]){
- if(argc == 1 || !strcmp(argv[1], “-h”)){
- help();
- }
- struct mii_ioctl_data *mii = NULL;
- struct ifreq ifr;
- int ret;
- memset(&ifr, 0, sizeof(ifr));
- strncpy(ifr.ifr_name, argv[1], IFNAMSIZ - 1);
- sockfd = socket(PF_LOCAL, SOCK_DGRAM, 0);
- reteck(sockfd);
- //get phy address in smi bus
- ret = ioctl(sockfd, SIOCGMIIPHY, &ifr);
- reteck(ret);
- mii = (struct mii_ioctl_data)&ifr.ifr_data;
- if(argc == 3){
- mii->reg_num = (uint16_t)strtoul(argv[2], NULL, 0);
- ret = ioctl(sockfd, SIOCGMIIREG, &ifr);
- reteck(ret);
- printf(”read phy addr: 0x%x reg: 0x%x value : 0x%x\n\n”, mii->phy_id, mii->reg_num, mii->val_out);
- }else if(argc == 4){
- mii->reg_num = (uint16_t)strtoul(argv[2], NULL, 0);
- mii->val_in = (uint16_t)strtoul(argv[3], NULL, 0);
- ret = ioctl(sockfd, SIOCSMIIREG, &ifr);
- reteck(ret);
- printf(”write phy addr: 0x%x reg: 0x%x value : 0x%x\n\n”, mii->phy_id, mii->reg_num, mii->val_in);
- }
- lab:
- close(sockfd);
- return 0;
- }
阅读全文
0 0
- 转载:linux+arm 网卡故障调试:ethtool&phy寄存器读写
- linux+arm 网卡故障调试:ethtool&phy寄存器读写
- linux 网卡参数 ethtool
- linux网卡信息-ethtool
- ARM-WinCE5.0-寄存器读写工具(转载 )
- ARM-WinCE6.0-寄存器读写工具(转载)
- linux网卡phy-mii驱动mdio调试zz150120a
- USB Phy/ULPI (2-读写USB Phy寄存器)
- linux 下 ethtool 修改网卡eeprom
- linux 下 ethtool 修改网卡eeprom
- linux 下 ethtool 修改网卡eeprom
- 读写寄存器调试技巧
- [转载]Linux服务器网卡驱动安装及故障排除
- arm平台linux移植ethtool工具
- Linux 下访问PHY芯片寄存器
- arm内部寄存器读写函数
- Linux下千兆网卡和万兆网卡ethtool对比
- Linux内核PHY中断调试
- SSM综合项目实战(TTSC) -- day02 Dubbo注册中心,通用Mapper,分页插件
- 金融科技&大数据产品推荐:Hyperchain--国产自主可控的企业级联盟区块链平台
- 比特币遭俄罗斯央行封禁,阿里成立全球研究机构“达摩院” | 大数据24小时
- java long 类型数据的赋值
- JavaScript表格隔行变色,鼠标移入表格展示背景颜色,鼠标移出颜色还原
- 转载:linux+arm 网卡故障调试:ethtool&phy寄存器读写
- Shiro学习笔记
- js中数值传递和引用传递
- UVa11419
- Tensorflow入门----占位符、常量和Session
- pycaffe读取caffemodel参数
- Docker实战:使用Dockerfile创建带Apache服务并支持ssh的Centos Docker镜像
- location.hash 与location.href
- mybatis #传值 与$传值区别