Linux RDMA and InfiniBand development
 help / color / mirror / Atom feed
* [PATCH for-upstream 1/1] RDMA/rxe: Replace netdev dev addr with raw_gid
@ 2025-03-01 19:33 Zhu Yanjun
  2025-03-02 12:39 ` Leon Romanovsky
  0 siblings, 1 reply; 3+ messages in thread
From: Zhu Yanjun @ 2025-03-01 19:33 UTC (permalink / raw)
  To: zyjzyj2000, jgg, leon, linux-rdma; +Cc: 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.

Fixes: 2ac5415022d1 ("RDMA/rxe: Remove the direct link to net_device")
Signed-off-by: Zhu Yanjun <yanjun.zhu@linux.dev>
---
 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(-)

diff --git a/drivers/infiniband/sw/rxe/rxe.c b/drivers/infiniband/sw/rxe/rxe.c
index 5f47c18ba938..00304101c715 100644
--- a/drivers/infiniband/sw/rxe/rxe.c
+++ b/drivers/infiniband/sw/rxe/rxe.c
@@ -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);
 }
 
diff --git a/drivers/infiniband/sw/rxe/rxe_verbs.c b/drivers/infiniband/sw/rxe/rxe_verbs.c
index 4f4b3285d818..3de4026897d5 100644
--- a/drivers/infiniband/sw/rxe/rxe_verbs.c
+++ b/drivers/infiniband/sw/rxe/rxe_verbs.c
@@ -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);
diff --git a/drivers/infiniband/sw/rxe/rxe_verbs.h b/drivers/infiniband/sw/rxe/rxe_verbs.h
index 040c89ec25e7..fd48075810dd 100644
--- a/drivers/infiniband/sw/rxe/rxe_verbs.h
+++ b/drivers/infiniband/sw/rxe/rxe_verbs.h
@@ -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;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH for-upstream 1/1] RDMA/rxe: Replace netdev dev addr with raw_gid
  2025-03-01 19:33 [PATCH for-upstream 1/1] RDMA/rxe: Replace netdev dev addr with raw_gid Zhu Yanjun
@ 2025-03-02 12:39 ` Leon Romanovsky
  2025-03-02 17:05   ` Zhu Yanjun
  0 siblings, 1 reply; 3+ messages in thread
From: Leon Romanovsky @ 2025-03-02 12:39 UTC (permalink / raw)
  To: Zhu Yanjun; +Cc: zyjzyj2000, jgg, linux-rdma

On Sat, Mar 01, 2025 at 08:33:51PM +0100, Zhu Yanjun wrote:
> 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")
> Signed-off-by: Zhu Yanjun <yanjun.zhu@linux.dev>
> ---
>  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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH for-upstream 1/1] RDMA/rxe: Replace netdev dev addr with raw_gid
  2025-03-02 12:39 ` Leon Romanovsky
@ 2025-03-02 17:05   ` Zhu Yanjun
  0 siblings, 0 replies; 3+ messages in thread
From: Zhu Yanjun @ 2025-03-02 17:05 UTC (permalink / raw)
  To: Leon Romanovsky; +Cc: zyjzyj2000, jgg, linux-rdma


在 2025/3/2 13:39, Leon Romanovsky 写道:
> On Sat, Mar 01, 2025 at 08:33:51PM +0100, Zhu Yanjun wrote:
>> 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")
>> Signed-off-by: Zhu Yanjun <yanjun.zhu@linux.dev>
>> ---
>>   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

>
> Thanks

-- 
Best Regards,
Yanjun.Zhu


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-03-02 17:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-01 19:33 [PATCH for-upstream 1/1] RDMA/rxe: Replace netdev dev addr with raw_gid Zhu Yanjun
2025-03-02 12:39 ` Leon Romanovsky
2025-03-02 17:05   ` Zhu Yanjun

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox