GMAC网卡Fixed-Link模式

GMAC

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属性


设备树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模式的更多相关文章

  1. GMAC网卡相关介绍与分析

    GMAC网卡相关介绍与分析 目录 GMAC网卡相关介绍与分析 环境描述 MII MII RMII GMII RGMII SGMII GMAC网卡信息获取方法 获取GMAC网卡信息 查看PHY工作接口模 ...

  2. ubuntu 设置网卡为混杂模式 以及网络配置命令

    1. ifconfig eth0 promisc 设置eth0为混杂模式. ifconfig eth0 -promisc 取消它的混杂模式 botnet@botnet-virtual-machine: ...

  3. centos配置单网卡为Trunk模式

    单网卡配置多IP(trunk模式)操作标准 1.linux的单网卡配置多IP的操作 下面为linux系统单网卡配置多IP(trunk模式)的操作步骤,系统平台为centos5.5.全部操作完成后,将实 ...

  4. 使用共享网卡的NAT模式配置VMware中的CentOS的上网功能

    昨天写了一篇文章总结了前两天折腾VMware 10中的CentOS上网的问题,结果留下一下小瑕疵,就是视频教程中通过共享网卡使用NAT模式配置虚拟机的方法.今天在结合昨天的基础上终于弄明白了这个问题. ...

  5. linux 网卡的混杂模式的取消

    1.Linux下网卡常用的几种模式说明: 广播方式:该模式下的网卡能够接收网络中的广播信息. 组播方式:设置在该模式下的网卡能够接收组播数据. 直接方式:在这种模式下,只有目的网卡才能接收该数据. 混 ...

  6. 看到了一篇博文,关于网卡的sniff模式,感觉相当好

    @font-face { font-family: "Times New Roman"; }@font-face { font-family: "宋体"; }@ ...

  7. 如何使用共享网卡的NAT模式配置VMware12中的CentOS6.7的上网功能

    1.首先共享网卡的NAT模式是通过win10中的VMnet8来通信的,如下双击VMnet8 2.点击[详细信息]查看VMnet8的IPV4地址为192.168.232.110,掩码为255.255.2 ...

  8. 使用wifi网卡笔记5---AP模式

    使用WIFI网卡的AP功能 1.下载源码 hostapd: http://w1.fi/hostapd/ 2.编译.安装(hostapd依赖于libnl库,需要编译.安装此库) tar xzf host ...

  9. 多网卡的bond模式-把多个物理网卡绑定成一个逻辑上的网卡

    参考: 多网卡的7种bond模式原理 如何实现网卡bond

  10. 在VMware中配置网卡之NAT模式

    为什么要在VMware中配置网卡? 因为在远程连接服务器时,需要虚拟机连接网络 虚拟机网络配置的三种模式:桥接模式,NAT模式,主机模式 NAT模式也称之为网络转换模式,两层路由: 第一层路由:物理机 ...

随机推荐

  1. 在Volo.Abp微服务中使用SignalR

    假设需要通过SignalR发送消息通知,并在前端接收消息通知的功能 创建SignalR服务 在项目中引用 abp add-package Volo.Abp.AspNetCore.SignalR 在Mo ...

  2. fastapi之helloworld

    简介 以下简介来自官网描述: FastAPI是一个用于构建API的现代.快速(高性能)的web框架,使用Python3.6+并基于标准的Python类型提示. 关键特性: 快速:可与NodeJS和Go ...

  3. C#利用Refit实现JWT自动续期

    前言 笔者之前开发过一套C/S架构的桌面应用,采用了JWT作为用户的登录认证和授权.遇到的唯一问题就是JWT过期了该怎么办?设想当一个用户正在进行业务操作,突然因为Token过期失效,莫名其妙地跳转到 ...

  4. 快手Java一面11问(附参考答案)

    现在已经到了面试招聘比较火热的时候,后续会分享一些面试真题供大家复习参考.准备面试的过程中,一定要多看面经,多自测! 今天分享的是一位贵州大学的同学分享的快手一面面经. 快手一面主要会问一些基础问题, ...

  5. P1113 杂务 (DAG拓扑排序--DP)

    这是一道拓扑排序的模板题 0 额. 所需的前置知识: 图论相关的基本概念 建图,存图 图的遍历 非常入门的DP 下面进入正文 1 引入 拓扑排序是一类用于处理 DAG(Directed acyclic ...

  6. TDD、BDD、ATDD都是什么、有什么区别?(上)

    软件开发是一个迭代过程,包括编写.测试和改进代码,直到满足需求.测试驱动开发(TDD).行为驱动开发(BDD)和验收测试驱动开发(ATDD)是支持该过程的三种方法.TDD.BDD和ATDD都是软件开发 ...

  7. [初学C#] 第二习题 : 快递跟踪信息查询

    刚学C#, 折腾的一个小玩意. 熟悉和了解C#这门编程语言. 没有啥特殊意义 解锁技能 - System.Net 的 WebRequest等http请求 - Newtonsoft.Json 这个第三方 ...

  8. .NET 8 Release Candidate 1 (RC1)现已发布,包括许多针对ASP.NET Core的重要改进!

    这是我们计划在今年晚些时候发布的最终.NET 8版本之前的两个候选版本中的第一个.大部分计划中的功能和变更都包含在这个候选版本中,可以供您尝试使用.您可以在文档中找到完整的ASP.NET Core在. ...

  9. day1项目配置

    项目初始化 本项目使用vite进行构建,vite参考官网 pnpm包管理:performant npm,意味"高性能的npm".pnpm由npm/yarn衍生而来,解决了npmly ...

  10. destoon上做纯js实现html指定页面导出word

    因为最近做了范文网站需要,所以要下载为word文档,如果php进行处理,很吃后台服务器,所以想用前端进行实现.查询github发现,确实有这方面的插件. js导出word文档所需要的两个插件: 1 2 ...