Skip to content

Commit f55c3ec

Browse files
Yuval Shaiajgunthorpe
authored andcommitted
IB/rxe: Reuse code which sets port state
Same code is executed in both rxe_param_set_add and rxe_notify functions. Make one function and call it from both places. Since both callers already have a rxe object use it directly instead of deriving it from the net device. Signed-off-by: Yuval Shaia <yuval.shaia@oracle.com> Reviewed-by: Steve Wise <swise@opengridcomputing.com>  Reviewed-by: Bart Van Assche <bart.vanassche@wdc.com> Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
1 parent d5108e6 commit f55c3ec

File tree

3 files changed

+11
-21
lines changed

3 files changed

+11
-21
lines changed

drivers/infiniband/sw/rxe/rxe.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,5 +110,6 @@ struct rxe_dev *get_rxe_by_name(const char *name);
110110

111111
void rxe_port_up(struct rxe_dev *rxe);
112112
void rxe_port_down(struct rxe_dev *rxe);
113+
void rxe_set_port_state(struct rxe_dev *rxe);
113114

114115
#endif /* RXE_H */

drivers/infiniband/sw/rxe/rxe_net.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -625,6 +625,14 @@ void rxe_port_down(struct rxe_dev *rxe)
625625
dev_info(&rxe->ib_dev.dev, "set down\n");
626626
}
627627

628+
void rxe_set_port_state(struct rxe_dev *rxe)
629+
{
630+
if (netif_running(rxe->ndev) && netif_carrier_ok(rxe->ndev))
631+
rxe_port_up(rxe);
632+
else
633+
rxe_port_down(rxe);
634+
}
635+
628636
static int rxe_notify(struct notifier_block *not_blk,
629637
unsigned long event,
630638
void *arg)
@@ -651,10 +659,7 @@ static int rxe_notify(struct notifier_block *not_blk,
651659
rxe_set_mtu(rxe, ndev->mtu);
652660
break;
653661
case NETDEV_CHANGE:
654-
if (netif_running(ndev) && netif_carrier_ok(ndev))
655-
rxe_port_up(rxe);
656-
else
657-
rxe_port_down(rxe);
662+
rxe_set_port_state(rxe);
658663
break;
659664
case NETDEV_REBOOT:
660665
case NETDEV_GOING_DOWN:

drivers/infiniband/sw/rxe/rxe_sysfs.c

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -53,22 +53,6 @@ static int sanitize_arg(const char *val, char *intf, int intf_len)
5353
return len;
5454
}
5555

56-
static void rxe_set_port_state(struct net_device *ndev)
57-
{
58-
struct rxe_dev *rxe = net_to_rxe(ndev);
59-
bool is_up = netif_running(ndev) && netif_carrier_ok(ndev);
60-
61-
if (!rxe)
62-
goto out;
63-
64-
if (is_up)
65-
rxe_port_up(rxe);
66-
else
67-
rxe_port_down(rxe); /* down for unknown state */
68-
out:
69-
return;
70-
}
71-
7256
static int rxe_param_set_add(const char *val, const struct kernel_param *kp)
7357
{
7458
int len;
@@ -104,7 +88,7 @@ static int rxe_param_set_add(const char *val, const struct kernel_param *kp)
10488
goto err;
10589
}
10690

107-
rxe_set_port_state(ndev);
91+
rxe_set_port_state(rxe);
10892
dev_info(&rxe->ib_dev.dev, "added %s\n", intf);
10993
err:
11094
if (ndev)

0 commit comments

Comments
 (0)