GMAC网卡Fixed-Link模式
GMAC网卡Fixed-Link模式
fixed-link固定链接模式,mac与对端的连接方式是写死的,通常用于mac to mac(不排除mac to phy的情况)。内核要支持fixed-link模式,需要打开CONFIG_FIXED_PHY配置。
社区版linux的gmac网卡platform平台驱动中,在设备树默认下支持fixed-link,gmac网卡platform平台驱动默认不支持ACPI模式。
fixed-link模式的实现,概括起来就两步,
- 通过
fixed_phy_register创建phy device - 连接phy device
fixed-link的link状态通常是固定的,但也可以通过gpio GPIOF_DIR_IN寄存器获取。
设备树Fixed-Link实现
以4.19.90内核版本为例其实现方式如下(内核版本5.3之后使用phylink替代了phy lib,实现接口有所不同):
设备树配置中定义fixed-link属性

stmac驱动实现,of_phy_register_fixed_link函数读取设备树fixed-link属性并通过fixed_phy_register创建phy device,of_phy_connect连接phy device。
stmmac_platform.c:
static int stmmac_dt_phy(struct plat_stmmacenet_data *plat,
struct device_node *np, struct device *dev)
{
... ...
/* If phy-handle is not specified, check if we have a fixed-phy */
if (!plat->phy_node && of_phy_is_fixed_link(np)) {
if ((of_phy_register_fixed_link(np) < 0))
return -ENODEV;
dev_dbg(dev, "Found fixed-link subnode\n");
plat->phy_node = of_node_get(np);
mdio = false;
}
... ...
}
stmmac_main.c:
static int stmmac_init_phy(struct net_device *dev)
{
... ...
if (priv->plat->phy_node) {
phydev = of_phy_connect(dev, priv->plat->phy_node,
&stmmac_adjust_link, 0, interface);
... ...
}
通过of_phy_register_fixed_link函数可知,fixed-link的配置方式不只一种。
/drivers/of/of_mdio.c:
int of_phy_register_fixed_link(struct device_node *np)
{
struct fixed_phy_status status = {};
struct device_node *fixed_link_node;
u32 fixed_link_prop[5];
const char *managed;
int link_gpio = -1;
if (of_property_read_string(np, "managed", &managed) == 0 &&
strcmp(managed, "in-band-status") == 0) {
/* status is zeroed, namely its .link member */
goto register_phy;
}
/* New binding */
fixed_link_node = of_get_child_by_name(np, "fixed-link");
if (fixed_link_node) {
status.link = 1;
status.duplex = of_property_read_bool(fixed_link_node,
"full-duplex");
if (of_property_read_u32(fixed_link_node, "speed",
&status.speed)) {
of_node_put(fixed_link_node);
return -EINVAL;
}
status.pause = of_property_read_bool(fixed_link_node, "pause");
status.asym_pause = of_property_read_bool(fixed_link_node,
"asym-pause");
link_gpio = of_get_named_gpio_flags(fixed_link_node,
"link-gpios", 0, NULL);
of_node_put(fixed_link_node);
if (link_gpio == -EPROBE_DEFER)
return -EPROBE_DEFER;
goto register_phy;
}
/* Old binding */
if (of_property_read_u32_array(np, "fixed-link", fixed_link_prop,
ARRAY_SIZE(fixed_link_prop)) == 0) {
status.link = 1;
status.duplex = fixed_link_prop[1];
status.speed = fixed_link_prop[2];
status.pause = fixed_link_prop[3];
status.asym_pause = fixed_link_prop[4];
goto register_phy;
}
return -ENODEV;
register_phy:
return PTR_ERR_OR_ZERO(fixed_phy_register(PHY_POLL, &status, link_gpio,
np));
}
EXPORT_SYMBOL(of_phy_register_fixed_link);
ACPI Fixed-Link实现
本质上ACPI和设备树fixed-link实现是一致的,只是部分接口函数不同,ACPI下可以使用phy_connect_direct进行连接(5.3之后的内核版本使用phylink模式,连接函数是phylink_connect_phy)。
stmmac_platform.c:
int fw_phy_register_fixed_link(struct fwnode_handle *np,
struct plat_stmmacenet_data *plat)
{
struct fixed_phy_status status = {};
u32 fixed_link_prop[5];
int size = 5, err;
int link_gpio = -1;
struct phy_device *phydev = NULL;
if (FORCE_FIXED_LINK) {
status.link = 1;
status.duplex = DUPLEX_FULL;
status.speed = SPEED_1000;
pr_info("force fixed-link busid %d\n", plat->bus_id);
} else {
err = fwnode_property_read_u32_array(np, "fixed-link", fixed_link_prop, size);
if (err) {
pr_err("----there is no fixed-link property in DSD--\n");
return 0;
}
status.link = 1;
status.duplex = fixed_link_prop[1];
status.speed = fixed_link_prop[2];
status.pause = fixed_link_prop[3];
status.asym_pause = fixed_link_prop[4];
}
phydev = fixed_phy_register(PHY_POLL, &status, link_gpio, 0);
if (IS_ERR(phydev)) {
pr_err("fixed_phy_register failed\n");
return -1;
}
plat->fixedphydev = phydev;
return 0;
}
stmmac_main.c:
static int stmmac_init_phy(struct net_device *dev)
{
... ...
if (priv->plat->fixedphydev) {
phydev = priv->plat->fixedphydev;
if (phy_connect_direct(dev, phydev, &stmmac_adjust_link,
interface)) {
netdev_err(priv->dev, "phy_connect_direct failed\n");
phydev = NULL;
}
... ...
}
GMAC网卡Fixed-Link模式的更多相关文章
- GMAC网卡相关介绍与分析
GMAC网卡相关介绍与分析 目录 GMAC网卡相关介绍与分析 环境描述 MII MII RMII GMII RGMII SGMII GMAC网卡信息获取方法 获取GMAC网卡信息 查看PHY工作接口模 ...
- ubuntu 设置网卡为混杂模式 以及网络配置命令
1. ifconfig eth0 promisc 设置eth0为混杂模式. ifconfig eth0 -promisc 取消它的混杂模式 botnet@botnet-virtual-machine: ...
- centos配置单网卡为Trunk模式
单网卡配置多IP(trunk模式)操作标准 1.linux的单网卡配置多IP的操作 下面为linux系统单网卡配置多IP(trunk模式)的操作步骤,系统平台为centos5.5.全部操作完成后,将实 ...
- 使用共享网卡的NAT模式配置VMware中的CentOS的上网功能
昨天写了一篇文章总结了前两天折腾VMware 10中的CentOS上网的问题,结果留下一下小瑕疵,就是视频教程中通过共享网卡使用NAT模式配置虚拟机的方法.今天在结合昨天的基础上终于弄明白了这个问题. ...
- linux 网卡的混杂模式的取消
1.Linux下网卡常用的几种模式说明: 广播方式:该模式下的网卡能够接收网络中的广播信息. 组播方式:设置在该模式下的网卡能够接收组播数据. 直接方式:在这种模式下,只有目的网卡才能接收该数据. 混 ...
- 看到了一篇博文,关于网卡的sniff模式,感觉相当好
@font-face { font-family: "Times New Roman"; }@font-face { font-family: "宋体"; }@ ...
- 如何使用共享网卡的NAT模式配置VMware12中的CentOS6.7的上网功能
1.首先共享网卡的NAT模式是通过win10中的VMnet8来通信的,如下双击VMnet8 2.点击[详细信息]查看VMnet8的IPV4地址为192.168.232.110,掩码为255.255.2 ...
- 使用wifi网卡笔记5---AP模式
使用WIFI网卡的AP功能 1.下载源码 hostapd: http://w1.fi/hostapd/ 2.编译.安装(hostapd依赖于libnl库,需要编译.安装此库) tar xzf host ...
- 多网卡的bond模式-把多个物理网卡绑定成一个逻辑上的网卡
参考: 多网卡的7种bond模式原理 如何实现网卡bond
- 在VMware中配置网卡之NAT模式
为什么要在VMware中配置网卡? 因为在远程连接服务器时,需要虚拟机连接网络 虚拟机网络配置的三种模式:桥接模式,NAT模式,主机模式 NAT模式也称之为网络转换模式,两层路由: 第一层路由:物理机 ...
随机推荐
- [ansible]建立ssh互信
创建密钥 # 创建基于rsa算法的密钥,也可以创建ed25519算法的密钥,性能比rsa高 # 一般直接回车即可 ssh-keygen -t rsa 少量建立互信 如果主机数不多的话,可以手动建立互信 ...
- msfvenom参数简介
-p, –payload < payload> 指定需要使用的payload(攻击荷载).也可以使用自定义payload,几乎是支持全平台的 -l, –list [module_type] ...
- devops之Python编程-类的基础架构
Python中,可以通过关键字class来定义一个类.类是一种自定义数据类型,它可以包含属性(变量)和方法(函数).下面是一个示例: class MyClass: def __init__(self, ...
- ETL之apache hop系列2-hop web安装和入门
前言 在Docker安装apache hop 首先确保Docker已经安装和运行Java 11 JDK 安装文档参考:https://blog.csdn.net/Chia_Hung_Yeh/artic ...
- CodeForces 1388C Uncle Bogdan and Country Happiness
题意 给一棵\(n\)节点的树,每个节点有\(a[i]\)个人住,他们从\(1\)号节点回家,回家路上可能从开心的状态变成不开心的状态(但不可以由不开心变为开心),每个节点有个探测器,会探测经过该节点 ...
- QA|新版Pycharm如何关闭和开启自动补全功能?|Pycharm|工具相关
自动补全开启状态: 自动补全关闭状态: 建议:新学者建议开启自动补全,这样可以把各个函数方法记忆的更加深刻!
- 聊透 GPU 通信技术——GPU Direct、NVLink、RDMA 审核中
最近人工智能大火,AI 应用所涉及的技术能力包括语音.图像.视频.NLP 等多方面,而这些都需要强大的计算资源支持.AI 技术对算力的需求是非常庞大的,虽然 GPU 的计算能力在持续提升,但是对于 A ...
- 云上的甜蜜早安:腾讯云云函数助力PHP打造女友专属每日推送
用腾讯云的云函数做一个微信公众号早安,每天定时发送早安给你的女朋友! 1.首先我们登录腾讯云,在搜索栏搜索云函数,或直接用这个链接进入curl.qcloud.com/Td0IkpmD 2.进入云函数, ...
- numpy中的nan (无穷小)注意点
- 【Python爬虫实战】爬虫封你ip就不会了?ip代理池安排上
前言 在进行网络爬取时,使用代理是经常遇到的问题.由于某些网站的限制,我们可能会被封禁或者频繁访问时会遇到访问速度变慢等问题.因此,我们需要使用代理池来避免这些问题.本文将为大家介绍如何使用IP代理池 ...