Skip to content

Commit af7a35b

Browse files
chiarameiohasrleon
authored andcommitted
RDMA/core: Implement RoCE GID port rescan and export delete function
rdma_roce_rescan_port() scans all network devices in the system and adds the gids if relevant to the RoCE device port. When not in bonding mode it adds the GIDs of the netdevice in this port. When in bonding mode it adds the GIDs of both the port's netdevice and the bond master netdevice. Export roce_del_all_netdev_gids(), which removes all GIDs associated with a specific netdevice for a given port. Signed-off-by: Chiara Meiohas <[email protected]> Link: https://patch.msgid.link/674d498da4637a1503ff1367e28bd09ff942fd5e.1730381292.git.leon@kernel.org Signed-off-by: Leon Romanovsky <[email protected]>
1 parent 6d9c7b2 commit af7a35b

File tree

2 files changed

+29
-4
lines changed

2 files changed

+29
-4
lines changed

drivers/infiniband/core/roce_gid_mgmt.c

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,27 @@ void rdma_roce_rescan_device(struct ib_device *ib_dev)
515515
}
516516
EXPORT_SYMBOL(rdma_roce_rescan_device);
517517

518+
/**
519+
* rdma_roce_rescan_port - Rescan all of the network devices in the system
520+
* and add their gids if relevant to the port of the RoCE device.
521+
*
522+
* @ib_dev: IB device
523+
* @port: Port number
524+
*/
525+
void rdma_roce_rescan_port(struct ib_device *ib_dev, u32 port)
526+
{
527+
struct net_device *ndev = NULL;
528+
529+
if (rdma_protocol_roce(ib_dev, port)) {
530+
ndev = ib_device_get_netdev(ib_dev, port);
531+
if (!ndev)
532+
return;
533+
enum_all_gids_of_dev_cb(ib_dev, port, ndev, ndev);
534+
dev_put(ndev);
535+
}
536+
}
537+
EXPORT_SYMBOL(rdma_roce_rescan_port);
538+
518539
static void callback_for_addr_gid_device_scan(struct ib_device *device,
519540
u32 port,
520541
struct net_device *rdma_ndev,
@@ -575,16 +596,17 @@ static void handle_netdev_upper(struct ib_device *ib_dev, u32 port,
575596
}
576597
}
577598

578-
static void _roce_del_all_netdev_gids(struct ib_device *ib_dev, u32 port,
579-
struct net_device *event_ndev)
599+
void roce_del_all_netdev_gids(struct ib_device *ib_dev,
600+
u32 port, struct net_device *ndev)
580601
{
581-
ib_cache_gid_del_all_netdev_gids(ib_dev, port, event_ndev);
602+
ib_cache_gid_del_all_netdev_gids(ib_dev, port, ndev);
582603
}
604+
EXPORT_SYMBOL(roce_del_all_netdev_gids);
583605

584606
static void del_netdev_upper_ips(struct ib_device *ib_dev, u32 port,
585607
struct net_device *rdma_ndev, void *cookie)
586608
{
587-
handle_netdev_upper(ib_dev, port, cookie, _roce_del_all_netdev_gids);
609+
handle_netdev_upper(ib_dev, port, cookie, roce_del_all_netdev_gids);
588610
}
589611

590612
static void add_netdev_upper_ips(struct ib_device *ib_dev, u32 port,

include/rdma/ib_verbs.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4734,6 +4734,9 @@ ib_get_vector_affinity(struct ib_device *device, int comp_vector)
47344734
* @device: the rdma device
47354735
*/
47364736
void rdma_roce_rescan_device(struct ib_device *ibdev);
4737+
void rdma_roce_rescan_port(struct ib_device *ib_dev, u32 port);
4738+
void roce_del_all_netdev_gids(struct ib_device *ib_dev,
4739+
u32 port, struct net_device *ndev);
47374740

47384741
struct ib_ucontext *ib_uverbs_get_ucontext_file(struct ib_uverbs_file *ufile);
47394742

0 commit comments

Comments
 (0)