Skip to content

Conversation

@rjarry
Copy link
Collaborator

@rjarry rjarry commented Dec 15, 2025

Register a callback for RTE_ETH_EVENT_INTR_RESET which is raised by some DPDK drivers when the hardware requires a reset. This typically happens when the PF driver modifies VF settings from the host side, for example when changing a VF MAC address via ip link:

ip link set $pf vf $vf_num mac $mac

When the reset event is received, the port is fully reset and reconfigured via rte_eth_dev_reset() followed by rte_eth_dev_configure() and rte_eth_dev_start(). The MAC address is re-read from hardware to pick up any changes made by the PF.

The callback is invoked from DPDK internal threads, so we use event_active() to defer the actual reset handling to the main control plane event loop.

Note that RTE_ETH_EVENT_INTR_RESET support varies by driver. The Intel iavf driver reports this event when the VF MAC is changed from the PF. The mlx5 driver does not report this event in the same scenario.

@coderabbitai
Copy link

coderabbitai bot commented Dec 15, 2025

📝 Walkthrough

Walkthrough

This change adds port reset handling: a new public bool needs_reset field is added to the port interface info structure. The implementation registers an interrupt callback for reset events, queues affected port IDs, and schedules a reset event in the main loop. On processing, ports are marked as needing reset and reconfiguration now stops a started port, performs a reset when needs_reset is set, clears the flag, and forces reconfiguration to ensure devices restart consistently. Initialization and teardown create/register and unregister/free the reset event and related data.


📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0b99d8c and 7eda18e.

📒 Files selected for processing (2)
  • modules/infra/control/gr_port.h (1 hunks)
  • modules/infra/control/port.c (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • modules/infra/control/port.c
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{c,h}

⚙️ CodeRabbit configuration file

**/*.{c,h}: - gr_vec_*() functions cannot fail. No need to check their return value.

  • gr_vec_free(x) always sets x = NULL. There is no risk of double free.
  • ec_node_*() functions consume their ec_node arguments. No leaks on error.
  • rte_node->ctx is an uint8_t array of size 16, not a pointer.
  • Never suggest to replace assert() with graceful error checking.
  • We compile with -std=gnu2x. Unnamed parameters in function definitions are valid.

Files:

  • modules/infra/control/gr_port.h
🧠 Learnings (1)
📓 Common learnings
Learnt from: maxime-leroy
Repo: DPDK/grout PR: 372
File: smoke/cross_vrf_forward_test.sh:18-18
Timestamp: 2025-11-05T13:55:26.189Z
Learning: In the DPDK/grout codebase, VRF interfaces (named gr-vrf<id>) are automatically created when an interface is added to a non-existing VRF using port_add. The VRF creation is handled automatically by the event system in vrf_netlink.c, so no explicit VRF interface creation commands are needed in test scripts.
🔇 Additional comments (1)
modules/infra/control/gr_port.h (1)

31-31: No thread-safety concern exists for the needs_reset field. The interrupt callback (intr_reset_cb) runs in DPDK threads but only queues port IDs in a mutex-protected vector—it never accesses needs_reset. The field is only accessed within the event loop context (port_reset_cb and iface_port_reconfig), which serializes all callbacks in a single thread, eliminating any race condition.

Likely an incorrect or invalid review comment.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e2f2dc7 and 0b99d8c.

📒 Files selected for processing (2)
  • modules/infra/control/gr_port.h (1 hunks)
  • modules/infra/control/port.c (3 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{c,h}

⚙️ CodeRabbit configuration file

**/*.{c,h}: - gr_vec_*() functions cannot fail. No need to check their return value.

  • gr_vec_free(x) always sets x = NULL. There is no risk of double free.
  • ec_node_*() functions consume their ec_node arguments. No leaks on error.
  • rte_node->ctx is an uint8_t array of size 16, not a pointer.
  • Never suggest to replace assert() with graceful error checking.
  • We compile with -std=gnu2x. Unnamed parameters in function definitions are valid.

Files:

  • modules/infra/control/gr_port.h
  • modules/infra/control/port.c
🧠 Learnings (1)
📓 Common learnings
Learnt from: maxime-leroy
Repo: DPDK/grout PR: 372
File: smoke/cross_vrf_forward_test.sh:18-18
Timestamp: 2025-11-05T13:55:26.189Z
Learning: In the DPDK/grout codebase, VRF interfaces (named gr-vrf<id>) are automatically created when an interface is added to a non-existing VRF using port_add. The VRF creation is handled automatically by the event system in vrf_netlink.c, so no explicit VRF interface creation commands are needed in test scripts.
🧬 Code graph analysis (1)
modules/infra/control/port.c (3)
modules/infra/control/port_test.c (1)
  • gr_datapath_rcu (27-30)
modules/infra/datapath/main_loop.c (1)
  • gr_datapath_rcu (300-302)
modules/infra/control/gr_iface.h (1)
  • iface (16-25)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
  • GitHub Check: build-and-tests (gcc-13, none, debugoptimized, ubuntu-24.04, -Dfrr=enabled, false)
  • GitHub Check: build-and-tests (clang-15, none, debugoptimized, ubuntu-22.04, false)
  • GitHub Check: rpm
  • GitHub Check: build-and-tests (clang-18, none, debugoptimized, ubuntu-24.04, false)
  • GitHub Check: build-and-tests (gcc-14, address, debug, ubuntu-24.04, -Dfrr=enabled, true)
  • GitHub Check: deb
  • GitHub Check: build-and-tests (clang-16, none, debugoptimized, ubuntu-24.04, false)

struct gr_iface_info_port api = {.mac = {{0}}};
LOG(INFO, "%s: port %u reset", iface->name, pid);
port->needs_reset = true;
iface_port_reconfig(iface, GR_PORT_SET_MAC, NULL, &api);
Copy link
Collaborator

Choose a reason for hiding this comment

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

IIUC, this will override any manually configured MAC on the port, won't it ?

On a side note, on a mac change event, do we trigger a gratuitous ARP and a NA message to tell all neighbors that the hardware address is modified ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

IIUC, this will override any manually configured MAC on the port, won't it ?

Yes indeed. Unfortunately, we don't have a way of knowing if the user had configured a specific mac address.

On a side note, on a mac change event, do we trigger a gratuitous ARP and a NA message to tell all neighbors that the hardware address is modified ?

We don't, but we should. Not only when there is a VF reset by the way. I can address this in a separate patch if that is OK.

Register a callback for RTE_ETH_EVENT_INTR_RESET which is raised by
some DPDK drivers when the hardware requires a reset. This typically
happens when the PF driver modifies VF settings from the host side,
for example when changing a VF MAC address via ip link:

  ip link set $pf vf $vf_num mac $mac

When the reset event is received, the port is fully reset and
reconfigured via rte_eth_dev_reset() followed by rte_eth_dev_configure()
and rte_eth_dev_start(). The MAC address is re-read from hardware to
pick up any changes made by the PF.

The DPDK callback may be invoked from internal threads and multiple
reset events can occur before the main event loop processes them. To
handle this, port IDs are queued in a mutex-protected vector and
processed in batch when the libevent callback fires.

Note that RTE_ETH_EVENT_INTR_RESET support varies by driver. The Intel
iavf driver reports this event when the VF MAC is changed from the PF.
The mlx5 driver does not report this event in the same scenario.

Signed-off-by: Robin Jarry <[email protected]>
Reviewed-by: Christophe Fontaine <[email protected]>
@christophefontaine christophefontaine merged commit 506fab4 into DPDK:main Dec 17, 2025
6 checks passed
@rjarry rjarry deleted the vf-reset branch December 18, 2025 08:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants