[PATCH v7 1/4] RDMA/rxe: remove rxe_ib_device_get_netdev() and RXE_PORT

zhenwei pi
2026-04-14T06:30:18Z

Suggested by Leon, remove the rxe_ib_device_get_netdev() wrapper and
the RXE_PORT definition. These additions do not improve readability,
and RXE has always had only a single port.

Signed-off-by: zhenwei pi <zhenwei.pi@linux.dev>
---
drivers/infiniband/sw/rxe/rxe_mcast.c | 4 ++--
drivers/infiniband/sw/rxe/rxe_net.c | 7 +++----
drivers/infiniband/sw/rxe/rxe_verbs.c | 4 ++--
drivers/infiniband/sw/rxe/rxe_verbs.h | 6 ------
4 files changed, 7 insertions(+), 14 deletions(-)

diff --git a/drivers/infiniband/sw/rxe/rxe_mcast.c b/drivers/infiniband/sw/rxe/rxe_mcast.c
index 5cad72073eca..acd03bd87794 100644
--- a/drivers/infiniband/sw/rxe/rxe_mcast.c
+++ b/drivers/infiniband/sw/rxe/rxe_mcast.c
@@ -34,7 +34,7 @@ static int rxe_mcast_add(struct rxe_dev *rxe, union ib_gid *mgid)
struct net_device *ndev;
int ret;

- ndev = rxe_ib_device_get_netdev(&rxe->ib_dev);
+ ndev = ib_device_get_netdev(&rxe->ib_dev, 1);
if (!ndev)
return -ENODEV;

@@ -59,7 +59,7 @@ static int rxe_mcast_del(struct rxe_dev *rxe, union ib_gid *mgid)
struct net_device *ndev;
int ret;

- ndev = rxe_ib_device_get_netdev(&rxe->ib_dev);
+ ndev = ib_device_get_netdev(&rxe->ib_dev, 1);
if (!ndev)
return -ENODEV;

diff --git a/drivers/infiniband/sw/rxe/rxe_net.c b/drivers/infiniband/sw/rxe/rxe_net.c
index 211bd3000acc..6621d01ac32d 100644
--- a/drivers/infiniband/sw/rxe/rxe_net.c
+++ b/drivers/infiniband/sw/rxe/rxe_net.c
@@ -602,7 +602,7 @@ const char *rxe_parent_name(struct rxe_dev *rxe, unsigned int port_num)
struct net_device *ndev;
char *ndev_name;

- ndev = rxe_ib_device_get_netdev(&rxe->ib_dev);
+ ndev = ib_device_get_netdev(&rxe->ib_dev, 1);
if (!ndev)
return NULL;
ndev_name = ndev->name;
@@ -646,12 +646,11 @@ static void rxe_sock_put(struct sock *sk,

void rxe_net_del(struct ib_device *dev)
{
- struct rxe_dev *rxe = container_of(dev, struct rxe_dev, ib_dev);
struct net_device *ndev;
struct sock *sk;
struct net *net;

- ndev = rxe_ib_device_get_netdev(&rxe->ib_dev);
+ ndev = ib_device_get_netdev(dev, 1);
if (!ndev)
return;

@@ -699,7 +698,7 @@ void rxe_set_port_state(struct rxe_dev *rxe)
{
struct net_device *ndev;

- ndev = rxe_ib_device_get_netdev(&rxe->ib_dev);
+ ndev = ib_device_get_netdev(&rxe->ib_dev, 1);
if (!ndev)
return;

diff --git a/drivers/infiniband/sw/rxe/rxe_verbs.c b/drivers/infiniband/sw/rxe/rxe_verbs.c
index 4d4891dc2884..eb17b6086d5e 100644
--- a/drivers/infiniband/sw/rxe/rxe_verbs.c
+++ b/drivers/infiniband/sw/rxe/rxe_verbs.c
@@ -50,7 +50,7 @@ static int rxe_query_port(struct ib_device *ibdev,
goto err_out;
}

- ndev = rxe_ib_device_get_netdev(ibdev);
+ ndev = ib_device_get_netdev(ibdev, 1);
if (!ndev) {
err = -ENODEV;
goto err_out;
@@ -1441,7 +1441,7 @@ static int rxe_enable_driver(struct ib_device *ib_dev)
struct rxe_dev *rxe = container_of(ib_dev, struct rxe_dev, ib_dev);
struct net_device *ndev;

- ndev = rxe_ib_device_get_netdev(ib_dev);
+ ndev = ib_device_get_netdev(ib_dev, 1);
if (!ndev)
return -ENODEV;

diff --git a/drivers/infiniband/sw/rxe/rxe_verbs.h b/drivers/infiniband/sw/rxe/rxe_verbs.h
index d92f80d16f78..e800545d1046 100644
--- a/drivers/infiniband/sw/rxe/rxe_verbs.h
+++ b/drivers/infiniband/sw/rxe/rxe_verbs.h
@@ -415,7 +415,6 @@ struct rxe_port {
u32 qp_gsi_index;
};

-#define RXE_PORT 1
struct rxe_dev {
struct ib_device ib_dev;
struct ib_device_attr attr;
@@ -451,11 +450,6 @@ struct rxe_dev {
struct rxe_port port;
};

-static inline struct net_device *rxe_ib_device_get_netdev(struct ib_device *dev)
-{
- return ib_device_get_netdev(dev, RXE_PORT);
-}
-
static inline void rxe_counter_inc(struct rxe_dev *rxe, enum rxe_counters index)
{
atomic64_inc(&rxe->stats_counters[index]);
--
2.43.0