Skip to contentSkip to conversation

RDMA/rxe: Replace netdev dev addr with raw_gid

PATCH In review Zhu Yanjun 2 participants 3 messages Mar 1, 2025 – Mar 2, 2025

Subsystems (2)
lore
Share & tools
lore

Zhu Yanjun

author
#0 lore raw

PATCH 1/1 RDMA/rxe: Replace netdev dev addr with raw_gid

Because TUN device does not have dev_addr, but a gid in rdma is needed, as such, a raw_gid is generated to act as the gid. The similar commit also exists in SIW. This commit learns from the similar commit bad5b6e34ffb ("RDMA/siw: Fabricate a GID on tun and loopback devices") in SIW.

Fixes 2ac5415022d1 ("RDMA/rxe: Remove the direct link to net_device")
---
 drivers/infiniband/sw/rxe/rxe.c       | 20 ++++----------------
 drivers/infiniband/sw/rxe/rxe_verbs.c |  2 +-
 drivers/infiniband/sw/rxe/rxe_verbs.h |  4 +++-
 3 files changed, 8 insertions(+), 18 deletions(-)
drivers/infiniband/sw/rxe/rxe.c +4 -16
index 5f47c18ba938..00304101c715 100644
@@ -37,8 +37,6 @@ void rxe_dealloc(struct ib_device *ib_dev)
 /* initialize rxe device parameters */
 static void rxe_init_device_param(struct rxe_dev *rxe)
 {
-	struct net_device *ndev;
-
 	rxe->max_inline_data			= RXE_MAX_INLINE_DATA;
 
 	rxe->attr.vendor_id			= RXE_VENDOR_ID;
@@ -70,17 +68,12 @@ static void rxe_init_device_param(struct rxe_dev *rxe)
 	rxe->attr.max_fast_reg_page_list_len	= RXE_MAX_FMR_PAGE_LIST_LEN;
 	rxe->attr.max_pkeys			= RXE_MAX_PKEYS;
 	rxe->attr.local_ca_ack_delay		= RXE_LOCAL_CA_ACK_DELAY;
+	rxe->max_ucontext			= RXE_MAX_UCONTEXT;
 
-	ndev = rxe_ib_device_get_netdev(&rxe->ib_dev);
-	if (!ndev)
-		return;
+	eth_random_addr(rxe->raw_gid);
 
 	addrconf_addr_eui48((unsigned char *)&rxe->attr.sys_image_guid,
-			ndev->dev_addr);
-
-	dev_put(ndev);
-
-	rxe->max_ucontext			= RXE_MAX_UCONTEXT;
+				rxe->raw_gid);
 
 	if (IS_ENABLED(CONFIG_INFINIBAND_ON_DEMAND_PAGING)) {
 		rxe->attr.kernel_cap_flags |= IBK_ON_DEMAND_PAGING;
@@ -133,15 +126,10 @@ static void rxe_init_port_param(struct rxe_port *port)
 static void rxe_init_ports(struct rxe_dev *rxe)
 {
 	struct rxe_port *port = &rxe->port;
-	struct net_device *ndev;
 
 	rxe_init_port_param(port);
-	ndev = rxe_ib_device_get_netdev(&rxe->ib_dev);
-	if (!ndev)
-		return;
 	addrconf_addr_eui48((unsigned char *)&port->port_guid,
-			    ndev->dev_addr);
-	dev_put(ndev);
+			    rxe->raw_gid);
 	spin_lock_init(&port->port_lock);
 }
 
drivers/infiniband/sw/rxe/rxe_verbs.c +1 -1
index 4f4b3285d818..3de4026897d5 100644
@@ -1526,7 +1526,7 @@ int rxe_register_device(struct rxe_dev *rxe, const char *ibdev_name,
 	dev->num_comp_vectors = num_possible_cpus();
 	dev->local_dma_lkey = 0;
 	addrconf_addr_eui48((unsigned char *)&dev->node_guid,
-			    ndev->dev_addr);
+				rxe->raw_gid);
 
 	dev->uverbs_cmd_mask |= BIT_ULL(IB_USER_VERBS_CMD_POST_SEND) |
 				BIT_ULL(IB_USER_VERBS_CMD_REQ_NOTIFY_CQ);
drivers/infiniband/sw/rxe/rxe_verbs.h +3 -1
index 040c89ec25e7..fd48075810dd 100644
@@ -413,7 +413,9 @@ struct rxe_dev {
 	struct ib_device_attr	attr;
 	int			max_ucontext;
 	int			max_inline_data;
-	struct mutex	usdev_lock;
+	struct mutex		usdev_lock;
+
+	char			raw_gid[ETH_ALEN];
 
 	struct rxe_pool		uc_pool;
 	struct rxe_pool		pd_pool;
Signature · 1 line
2.34.1
#1 lore raw
Quoted 6 lines · Zhu Yanjun

Because TUN device does not have dev_addr, but a gid in rdma is needed, as such, a raw_gid is generated to act as the gid. The similar commit also exists in SIW. This commit learns from the similar commit bad5b6e34ffb ("RDMA/siw: Fabricate a GID on tun and loopback devices") in SIW.

Quoted 7 lines
Fixes 2ac5415022d1 ("RDMA/rxe: Remove the direct link to net_device")
---
 drivers/infiniband/sw/rxe/rxe.c       | 20 ++++----------------
 drivers/infiniband/sw/rxe/rxe_verbs.c |  2 +-
 drivers/infiniband/sw/rxe/rxe_verbs.h |  4 +++-
 3 files changed, 8 insertions(+), 18 deletions(-)

This patch doesn't apply. It should be based on rdma-rc or rdma-next.

Thanks

author
#2 lore raw
Quoted 7 lines · Leon Romanovsky
Quoted 6 lines · Zhu Yanjun

Because TUN device does not have dev_addr, but a gid in rdma is needed, as such, a raw_gid is generated to act as the gid. The similar commit also exists in SIW. This commit learns from the similar commit bad5b6e34ffb ("RDMA/siw: Fabricate a GID on tun and loopback devices") in SIW.

Quoted 8 lines
Quoted 7 lines
Fixes 2ac5415022d1 ("RDMA/rxe: Remove the direct link to net_device")
---
  drivers/infiniband/sw/rxe/rxe.c       | 20 ++++----------------
  drivers/infiniband/sw/rxe/rxe_verbs.c |  2 +-
  drivers/infiniband/sw/rxe/rxe_verbs.h |  4 +++-
  3 files changed, 8 insertions(+), 18 deletions(-)

This patch doesn't apply. It should be based on rdma-rc or rdma-next.

Got you. I will send out a new patch for rdma-rc or rdma-next.

Best Regards,

Zhu Yanjun

Quoted 2 lines

Thanks

Signature · 2 lines
Best Regards,
Yanjun.Zhu