Skip to content

net: mucse: initial support for rnpm driver from Mucse Technology #867

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 11, 2025

Conversation

senbao
Copy link

@senbao senbao commented Jun 10, 2025

This driver is to support mucse n10/n400 4/8 ports ethernet card

update files:
arch/arm64/configs/deepin_arm64_desktop_defconfig
arch/loongarch/configs/deepin_loongarch_desktop_defconfig
arch/x86/configs/deepin_x86_desktop_defconfig
drivers/net/ethernet/mucse/Kconfig
drivers/net/ethernet/mucse/Makefile
drivers/net/ethernet/mucse/rnpm

Summary by Sourcery

Add initial Mucse Technology rnpm driver for n10/n400 multi-port 1/10Gb PCIe network cards

New Features:

  • Implement new rnpm driver supporting up to 8-port Mucse n10/n400 NICs
  • Introduce driver initialization, interrupt handling, Tx/Rx paths and offload features

Enhancements:

  • Register rnpm driver in Kconfig and Makefile under drivers/net/ethernet/mucse
  • Enable CONFIG_MXGBEM for rnpm in desktop defconfigs for arm64, loongarch and x86 architectures

Copy link

sourcery-ai bot commented Jun 10, 2025

Reviewer's Guide

This PR adds a new rnpm Ethernet driver for Mucse n10/n400 cards by introducing full driver code under drivers/net/ethernet/mucse/rnpm, wiring it into the build system via Kconfig and Makefile changes, and enabling it in the default Deepin desktop defconfigs for ARM64, LoongArch, and x86 platforms.

Sequence Diagram: Sysfs 'maintain' Operation for rnpm Driver

sequenceDiagram
    actor User
    participant Sysfs
    participant RnpmDriver["rnpm_adapter (rnpm_sysfs.c)"]
    participant DMAC["DMA Controller"]
    participant Hardware["Mucse NIC"]

    User->>+Sysfs: Write to 'maintain' (req_data)
    Sysfs->>+RnpmDriver: maintain_write(buf containing maintain_req, req_data)
    RnpmDriver->>+DMAC: Allocate DMA buffer (dma_buf)
    DMAC-->>-RnpmDriver: DMA buffer allocated (dma_phy)
    RnpmDriver->>RnpmDriver: Copy maintain_req, req_data to dma_buf
    RnpmDriver->>+Hardware: rnpm_maintain_req(cmd, arg0, ..., dma_phy)
    Hardware-->>-RnpmDriver: Operation complete (err_code)
    RnpmDriver->>RnpmDriver: If reply_bytes > 0, copy dma_buf to maintain_buf
    RnpmDriver->>+DMAC: Free DMA buffer (dma_buf, dma_phy)
    DMAC-->>-RnpmDriver: DMA buffer freed
    RnpmDriver-->>-Sysfs: Write complete
    Sysfs-->>-User: Write acknowledged

    User->>+Sysfs: Read from 'maintain'
    Sysfs->>+RnpmDriver: maintain_read(buf, offset, count)
    RnpmDriver->>RnpmDriver: Copy from maintain_buf to user buf
    RnpmDriver->>RnpmDriver: If end-of-buf, free maintain_buf
    RnpmDriver-->>-Sysfs: Data copied
    Sysfs-->>-User: Reply data
Loading

Class Diagram: rnpm_adapter Core Structure and Sysfs Data Types

classDiagram
    class rnpm_adapter {
        +net_device* netdev
        +pci_dev* pdev
        +rnpm_hw hw
        +rnpm_pf_adapter* pf_adapter
        +rnpm_ring* tx_ring[]
        +rnpm_ring* rx_ring[]
        +char* maintain_buf
        +void* maintain_dma_buf
        +u16 active_vlans[]
        +rnpm_sysfs_init() void
        +rnpm_sysfs_exit() void
        # maintain_write() ssize_t
        # maintain_read() ssize_t
        # active_vid_store() ssize_t
    }

    class rnpm_hw {
      +u8 __iomem* hw_addr
      +pci_dev* pdev
      +u16 device_id
      +u32 fw_version
      +rnpm_mac_info mac
      +rnpm_phy_info phy
      +rnpm_mbx_info mbx
      +rnpm_pcs_info pcs
      +rd32(reg) u32
      +wr32(reg, val) void
    }

    class rnpm_ring {
        +net_device* netdev
        +u16 rnpm_queue_idx
        +int count
        +int next_to_use
        +int next_to_clean
        +void* desc_ring_addr
        +rnpm_tx_desc* tx_descs
        +rnpm_rx_desc* rx_descs
    }

    class maintain_req {
      +int magic
      +int cmd
      +int arg0
      +int req_data_bytes
      +int reply_bytes
      +char data[]
    }

    class ucfg_mac_sn {
      +unsigned char macaddr[64]
      +unsigned char sn[32]
      +int magic
      +char rev[52]
      +unsigned char pn[32]
    }

    rnpm_adapter "1" *-- "1" rnpm_hw : contains
    rnpm_adapter "1" o-- "0..*" rnpm_ring : manages
    rnpm_adapter ..> maintain_req : uses_for_sysfs
    rnpm_adapter ..> ucfg_mac_sn : uses_for_sysfs
Loading

Class Diagram: rnpm_hw Structure and Hardware Abstraction Operations

classDiagram
    class rnpm_hw {
        +u8 __iomem* hw_addr
        +pci_dev* pdev
        +u16 device_id
        +u32 fw_version
        +rnpm_mac_info mac
        +rnpm_phy_info phy
        +rnpm_mbx_info mbx
        +rnpm_pcs_info pcs
        +rd32(reg) u32
        +wr32(reg, val) void
    }

    class rnpm_mac_info {
        +rnpm_mac_operations ops
        +u8 addr[6]
        +u8 perm_addr[6]
    }

    class rnpm_phy_info {
        +rnpm_phy_operations ops
        +rnpm_phy_type type
        +u32 id
    }

    class rnpm_mbx_info {
        +rnpm_mbx_operations ops
        +rnpm_mbx_stats stats
        +mutex* lock
    }

    class rnpm_pcs_info {
        +rnpm_pcs_operations ops
        +int pcs_count
    }

    class rnpm_mac_operations {
        <<Interface>>
        +init_hw(rnpm_hw*) s32
        +reset_hw(rnpm_hw*) s32
        +check_link(rnpm_hw*, rnpm_link_speed*, bool*, bool) s32
        +set_rar(rnpm_hw*, u32, u8*, u32, u32) s32
        +mac_loopback(rnpm_hw*, bool) bool
    }

    class rnpm_phy_operations {
        <<Interface>>
        +identify(rnpm_hw*) s32
        +init(rnpm_hw*) s32
        +read_reg(rnpm_hw*, u32, u32, u16*) s32
        +write_reg(rnpm_hw*, u32, u32, u16) s32
    }

    class rnpm_mbx_operations {
        <<Interface>>
        +init_params(rnpm_hw*) s32
        +read(rnpm_hw*, u32*, u16, MBX_ID) s32
        +write(rnpm_hw*, u32*, u16, MBX_ID) s32
    }

    class rnpm_pcs_operations {
        <<Interface>>
        +read(rnpm_hw*, int, u32) u32
        +write(rnpm_hw*, int, u32, u32) void
    }

    rnpm_hw "1" *-- "1" rnpm_mac_info : has
    rnpm_hw "1" *-- "1" rnpm_phy_info : has
    rnpm_hw "1" *-- "1" rnpm_mbx_info : has
    rnpm_hw "1" *-- "1" rnpm_pcs_info : has

    rnpm_mac_info ..> rnpm_mac_operations : uses
    rnpm_phy_info ..> rnpm_phy_operations : uses
    rnpm_mbx_info ..> rnpm_mbx_operations : uses
    rnpm_pcs_info ..> rnpm_pcs_operations : uses
Loading

File-Level Changes

Change Details Files
Introduce the new rnpm driver implementation
  • Create drivers/net/ethernet/mucse/rnpm directory
  • Add rnpm_main.c with core PCI, netdev, NAPI, interrupt and TX/RX paths
  • Add rnpm_mbx_fw.c for firmware mailbox messaging
  • Add rnpm_mpe.c to load and control MPE/RPU firmware
  • Add rnpm_tc.c for basic traffic-class rate control
drivers/net/ethernet/mucse/rnpm/rnpm_main.c
drivers/net/ethernet/mucse/rnpm/rnpm_mbx_fw.c
drivers/net/ethernet/mucse/rnpm/rnpm_mpe.c
drivers/net/ethernet/mucse/rnpm/rnpm_tc.c
Integrate driver into build system
  • Define CONFIG_MXGBEM option in Kconfig
  • Add obj-$(CONFIG_MXGBEM) += rnpm/ in Makefile for driver directory
drivers/net/ethernet/mucse/Kconfig
drivers/net/ethernet/mucse/Makefile
Enable the driver in default defconfigs
  • Turn on CONFIG_MXGBEM in deepin_arm64_desktop_defconfig
  • Turn on CONFIG_MXGBEM in deepin_loongarch_desktop_defconfig
  • Turn on CONFIG_MXGBEM in deepin_x86_desktop_defconfig
arch/arm64/configs/deepin_arm64_desktop_defconfig
arch/loongarch/configs/deepin_loongarch_desktop_defconfig
arch/x86/configs/deepin_x86_desktop_defconfig

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@deepin-ci-robot
Copy link

Hi @senbao. Thanks for your PR. 😃

@deepin-ci-robot
Copy link

Hi @senbao. Thanks for your PR.

I'm waiting for a deepin-community member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign opsiff for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@Avenger-285714
Copy link
Collaborator

/ok-to-test

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces initial support for the Mucse rnpm network driver, implementing key functionalities such as firmware mailbox handling, PHY/PCS, PTP, and MPE support.

  • Adds multiple new driver source files and header definitions under drivers/net/ethernet/mucse/rnpm
  • Integrates build and configuration support via updates to Makefiles, Kconfig, and defconfig files
  • Implements several protocols and hardware interfaces including TC parsing, PHY operations, and MPE firmware handling

Reviewed Changes

Copilot reviewed 35 out of 35 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
drivers/net/ethernet/mucse/rnpm/version.h Introduces a version header including Git commit identifier
drivers/net/ethernet/mucse/rnpm/rnpm_tc_u32_parse.h Provides functions for parsing TC U32 filter values
drivers/net/ethernet/mucse/rnpm/rnpm_tc.h Declares interfaces for TC handling
drivers/net/ethernet/mucse/rnpm/rnpm_tc.c Implements TC related functions
drivers/net/ethernet/mucse/rnpm/rnpm_sriov.h Declares SR-IOV functions
drivers/net/ethernet/mucse/rnpm/rnpm_ptp.h Defines constants and functions for PTP timestamp operations
drivers/net/ethernet/mucse/rnpm/rnpm_phy.h Declares PHY-related operations
drivers/net/ethernet/mucse/rnpm/rnpm_phy.c Implements generic PHY operations
drivers/net/ethernet/mucse/rnpm/rnpm_pcs.h & .c Provide PCS register access operations
drivers/net/ethernet/mucse/rnpm/rnpm_n10.c Implements NIC-specific functionality including MAC address retrieval
drivers/net/ethernet/mucse/rnpm/rnpm_mpe.h & .c Implements MPE and RPU firmware download and control functions
drivers/net/ethernet/mucse/rnpm/rnpm_mbx.h Declares mailbox interface functions
drivers/net/ethernet/mucse/rnpm/Makefile Specifies the new rnpm object file list for compilation
drivers/net/ethernet/mucse/Makefile Updates build integration to include the new rnpm driver
arch//deepin__desktop_defconfig Enables CONFIG_MXGBEM for all supported architectures
drivers/net/ethernet/mucse/Kconfig Adds a new Kconfig entry for the MXGBEM driver
Comments suppressed due to low confidence (3)

drivers/net/ethernet/mucse/rnpm/rnpm_ptp.h:37

  • Clarify and correct the comment describing PTP timestamping; the current phrasing is unclear and contains typos.
/* Note 802.1 AS Is work Over Ethernet FramesC_Sub_Second_Incremen

drivers/net/ethernet/mucse/rnpm/rnpm_mpe.c:37

  • Typo in macro name 'iowrite32_arrary' should be corrected to 'iowrite32_array' for clarity and consistency.
#define iowrite32_arrary(rpubase, offset, array, size) \

drivers/net/ethernet/mucse/rnpm/rnpm_mpe.c:185

  • Correct the typo 'imvalid' to 'invalid' in the error message to avoid confusion.
dev_err(&pf_adapter->pdev->dev, "imvalid mpe bin. magic-code error\n");


struct rnpm_match_parser {
int off; /* the skb offset begin form the 12 bytes mac_type */
/* parse the value/mask to realy value*/
Copy link
Preview

Copilot AI Jun 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct the typo 'realy' to 'real' or 'actual' for clarity in the comment.

Suggested change
/* parse the value/mask to realy value*/
/* parse the value/mask to real value*/

Copilot uses AI. Check for mistakes.

memcpy(&f->filter.formatted.src_ip_mask[0], &mask, sizeof(u32));

f->filter.formatted.flow_type = RNPM_ATR_FLOW_TYPE_IPV4;
f->filter.layer2_formate.proto = htons(ETH_P_IP);
Copy link
Preview

Copilot AI Jun 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider correcting 'layer2_formate' to 'layer2_format' to improve naming clarity.

Suggested change
f->filter.layer2_formate.proto = htons(ETH_P_IP);
f->filter.layer2_format.proto = htons(ETH_P_IP);

Copilot uses AI. Check for mistakes.

if (hw->phy.reset_disable == false && hw->phy.ops.reset != NULL)
hw->phy.ops.reset(hw);
if (!(hw->mac.mac_flags & RNPM_FLAGS_INIT_MAC_ADDRESS)) {
rnpm_get_permtion_mac_addr(hw, hw->mac.perm_addr);
Copy link
Preview

Copilot AI Jun 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct 'permtion' to 'permission' to reflect the intended meaning.

Suggested change
rnpm_get_permtion_mac_addr(hw, hw->mac.perm_addr);
rnpm_get_permission_mac_addr(hw, hw->mac.perm_addr);

Copilot uses AI. Check for mistakes.

@senbao senbao force-pushed the rnpm_uos6.6 branch 4 times, most recently from 6cd07d3 to 13b97de Compare June 10, 2025 10:15
@senbao
Copy link
Author

senbao commented Jun 11, 2025

I deleted this error code long ago. Why does it still keep reporting this non-existent code? I have recompiled it 4 times

@senbao senbao closed this Jun 11, 2025
@senbao senbao reopened this Jun 11, 2025
This driver is to support mucse n10/n400 4/8 ports ethernet card

Signed-off-by: gu.huiguang <[email protected]>
@deepin-ci-robot
Copy link

deepin pr auto review

--
2.25.1

@opsiff
Copy link
Member

opsiff commented Jun 11, 2025

I deleted this error code long ago. Why does it still keep reporting this non-existent code? I have recompiled it 4 times

Just ignore it.

@Avenger-285714 Avenger-285714 merged commit b875bfd into deepin-community:linux-6.6.y Jun 11, 2025
5 of 8 checks passed
@Avenger-285714
Copy link
Collaborator

I deleted this error code long ago. Why does it still keep reporting this non-existent code? I have recompiled it 4 times

You got me.
This PR simply won't compile...
Our pipeline is just too slow, and he kept force-pushing new content, which caused the build failures to go unnoticed.
Never mind, I'll fix this immediately.

@Avenger-285714
Copy link
Collaborator

@senbao Please also check LLVM compilation next time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants