Align with the existing code:
static ... rxe_ib_device_get_netdev(struct ib_device *dev)
{
return ib_device_get_netdev(dev, RXE_PORT);
}
Use *RXE_PORT* instead of magic number 1 for all.
Signed-off-by: zhenwei pi <zhenwei.pi@linux.dev>
---
drivers/infiniband/sw/rxe/rxe_net.c | 6 +++---
drivers/infiniband/sw/rxe/rxe_verbs.c | 8 ++++----
2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/drivers/infiniband/sw/rxe/rxe_net.c b/drivers/infiniband/sw/rxe/rxe_net.c
index 0bd0902b11f7..20338cb8e3c2 100644
--- a/drivers/infiniband/sw/rxe/rxe_net.c
+++ b/drivers/infiniband/sw/rxe/rxe_net.c
@@ -234,7 +234,7 @@ static int rxe_udp_encap_recv(struct sock *sk, struct sk_buff *skb)
udph = udp_hdr(skb);
pkt->rxe = rxe;
- pkt->port_num = 1;
+ pkt->port_num = RXE_PORT;
pkt->hdr = (u8 *)(udph + 1);
pkt->mask = RXE_GRH_MASK;
pkt->paylen = be16_to_cpu(udph->len) - sizeof(*udph);
@@ -535,7 +535,7 @@ struct sk_buff *rxe_init_packet(struct rxe_dev *rxe, struct rxe_av *av,
struct sk_buff *skb = NULL;
struct net_device *ndev;
const struct ib_gid_attr *attr;
- const int port_num = 1;
+ const int port_num = RXE_PORT;
attr = rdma_get_gid_attr(&rxe->ib_dev, port_num, av->grh.sgid_index);
if (IS_ERR(attr))
@@ -630,7 +630,7 @@ static void rxe_port_event(struct rxe_dev *rxe,
struct ib_event ev;
ev.device = &rxe->ib_dev;
- ev.element.port_num = 1;
+ ev.element.port_num = RXE_PORT;
ev.event = event;
ib_dispatch_event(&ev);
diff --git a/drivers/infiniband/sw/rxe/rxe_verbs.c b/drivers/infiniband/sw/rxe/rxe_verbs.c
index fe41362c5144..bcd486e8668b 100644
--- a/drivers/infiniband/sw/rxe/rxe_verbs.c
+++ b/drivers/infiniband/sw/rxe/rxe_verbs.c
@@ -44,7 +44,7 @@ static int rxe_query_port(struct ib_device *ibdev,
struct net_device *ndev;
int err, ret;
- if (port_num != 1) {
+ if (port_num != RXE_PORT) {
err = -EINVAL;
rxe_dbg_dev(rxe, "bad port_num = %d\n", port_num);
goto err_out;
@@ -147,7 +147,7 @@ static int rxe_modify_port(struct ib_device *ibdev, u32 port_num,
struct rxe_port *port;
int err;
- if (port_num != 1) {
+ if (port_num != RXE_PORT) {
err = -EINVAL;
rxe_dbg_dev(rxe, "bad port_num = %d\n", port_num);
goto err_out;
@@ -180,7 +180,7 @@ static enum rdma_link_layer rxe_get_link_layer(struct ib_device *ibdev,
struct rxe_dev *rxe = to_rdev(ibdev);
int err;
- if (port_num != 1) {
+ if (port_num != RXE_PORT) {
err = -EINVAL;
rxe_dbg_dev(rxe, "bad port_num = %d\n", port_num);
goto err_out;
@@ -200,7 +200,7 @@ static int rxe_port_immutable(struct ib_device *ibdev, u32 port_num,
struct ib_port_attr attr = {};
int err;
- if (port_num != 1) {
+ if (port_num != RXE_PORT) {
err = -EINVAL;
rxe_dbg_dev(rxe, "bad port_num = %d\n", port_num);
goto err_out;
--
2.43.0
在 2026/3/28 22:41, zhenwei pi 写道:
> Align with the existing code:
> static ... rxe_ib_device_get_netdev(struct ib_device *dev)
> {
> return ib_device_get_netdev(dev, RXE_PORT);
> }
>
> Use *RXE_PORT* instead of magic number 1 for all.
>
Thanks a lot.
Reviewed-by: Zhu Yanjun <yanjun.zhu@linux.dev>
Zhu Yanjun
> Signed-off-by: zhenwei pi <zhenwei.pi@linux.dev>
> ---
> drivers/infiniband/sw/rxe/rxe_net.c | 6 +++---
> drivers/infiniband/sw/rxe/rxe_verbs.c | 8 ++++----
> 2 files changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/infiniband/sw/rxe/rxe_net.c b/drivers/infiniband/sw/rxe/rxe_net.c
> index 0bd0902b11f7..20338cb8e3c2 100644
> --- a/drivers/infiniband/sw/rxe/rxe_net.c
> +++ b/drivers/infiniband/sw/rxe/rxe_net.c
> @@ -234,7 +234,7 @@ static int rxe_udp_encap_recv(struct sock *sk, struct sk_buff *skb)
>
> udph = udp_hdr(skb);
> pkt->rxe = rxe;
> - pkt->port_num = 1;
> + pkt->port_num = RXE_PORT;
> pkt->hdr = (u8 *)(udph + 1);
> pkt->mask = RXE_GRH_MASK;
> pkt->paylen = be16_to_cpu(udph->len) - sizeof(*udph);
> @@ -535,7 +535,7 @@ struct sk_buff *rxe_init_packet(struct rxe_dev *rxe, struct rxe_av *av,
> struct sk_buff *skb = NULL;
> struct net_device *ndev;
> const struct ib_gid_attr *attr;
> - const int port_num = 1;
> + const int port_num = RXE_PORT;
>
> attr = rdma_get_gid_attr(&rxe->ib_dev, port_num, av->grh.sgid_index);
> if (IS_ERR(attr))
> @@ -630,7 +630,7 @@ static void rxe_port_event(struct rxe_dev *rxe,
> struct ib_event ev;
>
> ev.device = &rxe->ib_dev;
> - ev.element.port_num = 1;
> + ev.element.port_num = RXE_PORT;
> ev.event = event;
>
> ib_dispatch_event(&ev);
> diff --git a/drivers/infiniband/sw/rxe/rxe_verbs.c b/drivers/infiniband/sw/rxe/rxe_verbs.c
> index fe41362c5144..bcd486e8668b 100644
> --- a/drivers/infiniband/sw/rxe/rxe_verbs.c
> +++ b/drivers/infiniband/sw/rxe/rxe_verbs.c
> @@ -44,7 +44,7 @@ static int rxe_query_port(struct ib_device *ibdev,
> struct net_device *ndev;
> int err, ret;
>
> - if (port_num != 1) {
> + if (port_num != RXE_PORT) {
> err = -EINVAL;
> rxe_dbg_dev(rxe, "bad port_num = %d\n", port_num);
> goto err_out;
> @@ -147,7 +147,7 @@ static int rxe_modify_port(struct ib_device *ibdev, u32 port_num,
> struct rxe_port *port;
> int err;
>
> - if (port_num != 1) {
> + if (port_num != RXE_PORT) {
> err = -EINVAL;
> rxe_dbg_dev(rxe, "bad port_num = %d\n", port_num);
> goto err_out;
> @@ -180,7 +180,7 @@ static enum rdma_link_layer rxe_get_link_layer(struct ib_device *ibdev,
> struct rxe_dev *rxe = to_rdev(ibdev);
> int err;
>
> - if (port_num != 1) {
> + if (port_num != RXE_PORT) {
> err = -EINVAL;
> rxe_dbg_dev(rxe, "bad port_num = %d\n", port_num);
> goto err_out;
> @@ -200,7 +200,7 @@ static int rxe_port_immutable(struct ib_device *ibdev, u32 port_num,
> struct ib_port_attr attr = {};
> int err;
>
> - if (port_num != 1) {
> + if (port_num != RXE_PORT) {
> err = -EINVAL;
> rxe_dbg_dev(rxe, "bad port_num = %d\n", port_num);
> goto err_out;
© 2016 - 2026 Red Hat, Inc.