1 Star 0 Fork 52

invincibler/opensource-intern

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
dcb.rst 4.60 KB
一键复制 编辑 原始数据 按行查看 历史

Overview

The dcb module implements support for Data Center Bridging (DCB), which is a set of Ethernet enhancements that allow different types of network traffic with varying requirements (such as high reliability, no packet loss, and low latency) to coexist on the same Ethernet link. The main features of DCB include:

  • Enhanced Transmission Selection (ETS): Provides a framework for assigning bandwidth guarantees to traffic classes.
  • Priority-based Flow Control (PFC): Offers flow control mechanisms that can work independently for each 802.1p priority.
  • Congestion Notification: Provides end-to-end congestion control for protocols without built-in congestion management.

Key Files

  • dcbevent.c: Manages event notifications related to DCB.
  • dcbnl.c: Implements the rtnetlink interface for configuring DCB features.

Function Descriptions

### dcbevent.c

Function Description The dcbevent.c file contains functions for managing event notifications related to DCB, allowing other kernel components to be notified of changes or events.

int register_dcbevent_notifier(struct notifier_block *nb)
{
    return atomic_notifier_chain_register(&dcbevent_notif_chain, nb);
}

int unregister_dcbevent_notifier(struct notifier_block *nb)
{
    return atomic_notifier_chain_unregister(&dcbevent_notif_chain, nb);
}

int call_dcbevent_notifiers(unsigned long val, void *v)
{
    return atomic_notifier_call_chain(&dcbevent_notif_chain, val, v);
}

Open Capabilities - Custom Notifier Registration: Developers can create their own notifier_block structures and use register_dcbevent_notifier to receive notifications about DCB-related events. - Event Handling: By implementing the notifier_call function within the notifier_block, developers can define custom behavior in response to DCB events.

### dcbnl.c

Function Description The dcbnl.c file provides the rtnetlink interface for configuring DCB features, including setting and getting parameters for ETS, PFC, and application priorities.

static int dcbnl_getstate(struct net_device *netdev, struct nlmsghdr *nlh,
                         u32 seq, struct nlattr **tb, struct sk_buff *skb)
{
    if (!netdev->dcbnl_ops->getstate)
        return -EOPNOTSUPP;
    return nla_put_u8(skb, DCB_ATTR_STATE, netdev->dcbnl_ops->getstate(netdev));
}

static int dcbnl_getpfccfg(struct net_device *netdev, struct nlmsghdr *nlh,
                           u32 seq, struct nlattr **tb, struct sk_buff *skb)
{
    struct nlattr *data[DCB_PFC_UP_ATTR_MAX + 1], *nest;
    u8 value;
    int ret;
    int i;
    int getall = 0;

    if (!tb[DCB_ATTR_PFC_CFG])
        return -EINVAL;
    if (!netdev->dcbnl_ops->getpfccfg)
        return -EOPNOTSUPP;
    ret = nla_parse_nested_deprecated(data, DCB_PFC_UP_ATTR_MAX,
                                      tb[DCB_ATTR_PFC_CFG],
                                      dcbnl_pfc_up_nest, NULL);
    if (ret)
        return ret;

    nest = nla_nest_start_noflag(skb, DCB_ATTR_PFC_CFG);
    if (!nest)
        return -EMSGSIZE;

    if (data[DCB_PFC_UP_ATTR_ALL])
        getall = 1;

    for (i = DCB_PFC_UP_ATTR_0; i <= DCB_PFC_UP_ATTR_7; i++) {
        if (!getall && !data[i])
            continue;
        netdev->dcbnl_ops->getpfccfg(netdev, i - DCB_PFC_UP_ATTR_0, &value);
        ret = nla_put_u8(skb, i, value);
        if (ret)
    //Part of the source code is omitted here
}

Open Capabilities - Configuration Access: Developers can access and modify the DCB configuration of network devices through the provided rtnetlink operations. - Custom Feature Support: By extending the dcbnl_ops structure, developers can add support for additional DCB features or customize existing ones.

Open Capabilities

  • Notification System Extension: Developers can extend the notification system by adding new notifiers to handle specific events.
  • rtnetlink Interface Customization: Through the rtnetlink API, developers can implement custom logic to interact with the DCB settings of network interfaces, such as retrieving or updating configurations.
  • Device-Specific Enhancements: By modifying or extending the dcbnl_ops structure, developers can tailor the DCB functionality to better fit the needs of specific network hardware.
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/yuanrui2024/opensource-intern.git
git@gitee.com:yuanrui2024/opensource-intern.git
yuanrui2024
opensource-intern
opensource-intern
master

搜索帮助