mirror of
https://github.com/torvalds/linux.git
synced 2026-05-28 17:13:52 +02:00
RDMA/hns: Add helpers to obtain netdev and bus_num from hr_dev
Add helpers to obtain netdev and bus_num from hr_dev. Signed-off-by: Junxian Huang <huangjunxian6@hisilicon.com> Link: https://patch.msgid.link/20251112093510.3696363-2-huangjunxian6@hisilicon.com Signed-off-by: Leon Romanovsky <leon@kernel.org>
This commit is contained in:
parent
04e031ff6e
commit
cdb3a6f183
|
|
@ -30,7 +30,6 @@
|
|||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <linux/pci.h>
|
||||
#include <rdma/ib_addr.h>
|
||||
#include <rdma/ib_cache.h>
|
||||
#include "hns_roce_device.h"
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@
|
|||
#ifndef _HNS_ROCE_DEVICE_H
|
||||
#define _HNS_ROCE_DEVICE_H
|
||||
|
||||
#include <linux/pci.h>
|
||||
#include <rdma/ib_verbs.h>
|
||||
#include <rdma/hns-abi.h>
|
||||
#include "hns_roce_debugfs.h"
|
||||
|
|
@ -1165,6 +1166,17 @@ static inline u8 get_tclass(const struct ib_global_route *grh)
|
|||
grh->traffic_class >> DSCP_SHIFT : grh->traffic_class;
|
||||
}
|
||||
|
||||
static inline struct net_device *get_hr_netdev(struct hns_roce_dev *hr_dev,
|
||||
u8 port)
|
||||
{
|
||||
return hr_dev->iboe.netdevs[port];
|
||||
}
|
||||
|
||||
static inline u8 get_hr_bus_num(struct hns_roce_dev *hr_dev)
|
||||
{
|
||||
return hr_dev->pci_dev->bus->number;
|
||||
}
|
||||
|
||||
void hns_roce_init_uar_table(struct hns_roce_dev *dev);
|
||||
int hns_roce_uar_alloc(struct hns_roce_dev *dev, struct hns_roce_uar *uar);
|
||||
|
||||
|
|
|
|||
|
|
@ -32,7 +32,6 @@
|
|||
*/
|
||||
#include <linux/acpi.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/pci.h>
|
||||
#include <rdma/ib_addr.h>
|
||||
#include <rdma/ib_smi.h>
|
||||
#include <rdma/ib_user_verbs.h>
|
||||
|
|
@ -148,12 +147,13 @@ static int hns_roce_netdev_event(struct notifier_block *self,
|
|||
|
||||
static int hns_roce_setup_mtu_mac(struct hns_roce_dev *hr_dev)
|
||||
{
|
||||
struct net_device *net_dev;
|
||||
int ret;
|
||||
u8 i;
|
||||
|
||||
for (i = 0; i < hr_dev->caps.num_ports; i++) {
|
||||
ret = hns_roce_set_mac(hr_dev, i,
|
||||
hr_dev->iboe.netdevs[i]->dev_addr);
|
||||
net_dev = get_hr_netdev(hr_dev, i);
|
||||
ret = hns_roce_set_mac(hr_dev, i, net_dev->dev_addr);
|
||||
if (ret)
|
||||
return ret;
|
||||
}
|
||||
|
|
@ -246,7 +246,7 @@ static int hns_roce_query_port(struct ib_device *ib_dev, u32 port_num,
|
|||
|
||||
spin_lock_irqsave(&hr_dev->iboe.lock, flags);
|
||||
|
||||
net_dev = hr_dev->iboe.netdevs[port];
|
||||
net_dev = get_hr_netdev(hr_dev, port);
|
||||
if (!net_dev) {
|
||||
spin_unlock_irqrestore(&hr_dev->iboe.lock, flags);
|
||||
dev_err(dev, "find netdev %u failed!\n", port);
|
||||
|
|
@ -704,11 +704,12 @@ static const struct ib_device_ops hns_roce_dev_restrack_ops = {
|
|||
|
||||
static int hns_roce_register_device(struct hns_roce_dev *hr_dev)
|
||||
{
|
||||
int ret;
|
||||
struct hns_roce_ib_iboe *iboe = NULL;
|
||||
struct ib_device *ib_dev = NULL;
|
||||
struct device *dev = hr_dev->dev;
|
||||
struct ib_device *ib_dev = NULL;
|
||||
struct net_device *net_dev;
|
||||
unsigned int i;
|
||||
int ret;
|
||||
|
||||
iboe = &hr_dev->iboe;
|
||||
spin_lock_init(&iboe->lock);
|
||||
|
|
@ -744,11 +745,11 @@ static int hns_roce_register_device(struct hns_roce_dev *hr_dev)
|
|||
ib_set_device_ops(ib_dev, &hns_roce_dev_ops);
|
||||
ib_set_device_ops(ib_dev, &hns_roce_dev_restrack_ops);
|
||||
for (i = 0; i < hr_dev->caps.num_ports; i++) {
|
||||
if (!hr_dev->iboe.netdevs[i])
|
||||
net_dev = get_hr_netdev(hr_dev, i);
|
||||
if (!net_dev)
|
||||
continue;
|
||||
|
||||
ret = ib_device_set_netdev(ib_dev, hr_dev->iboe.netdevs[i],
|
||||
i + 1);
|
||||
ret = ib_device_set_netdev(ib_dev, net_dev, i + 1);
|
||||
if (ret)
|
||||
return ret;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,7 +30,6 @@
|
|||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <linux/pci.h>
|
||||
#include "hns_roce_device.h"
|
||||
|
||||
void hns_roce_init_pd_table(struct hns_roce_dev *hr_dev)
|
||||
|
|
|
|||
|
|
@ -31,7 +31,6 @@
|
|||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <linux/pci.h>
|
||||
#include <rdma/ib_addr.h>
|
||||
#include <rdma/ib_umem.h>
|
||||
#include <rdma/uverbs_ioctl.h>
|
||||
|
|
@ -1350,11 +1349,13 @@ static int check_mtu_validate(struct hns_roce_dev *hr_dev,
|
|||
struct hns_roce_qp *hr_qp,
|
||||
struct ib_qp_attr *attr, int attr_mask)
|
||||
{
|
||||
struct net_device *net_dev;
|
||||
enum ib_mtu active_mtu;
|
||||
int p;
|
||||
|
||||
p = attr_mask & IB_QP_PORT ? (attr->port_num - 1) : hr_qp->port;
|
||||
active_mtu = iboe_get_mtu(hr_dev->iboe.netdevs[p]->mtu);
|
||||
net_dev = get_hr_netdev(hr_dev, p);
|
||||
active_mtu = iboe_get_mtu(net_dev->mtu);
|
||||
|
||||
if ((hr_dev->caps.max_mtu >= IB_MTU_2048 &&
|
||||
attr->path_mtu > hr_dev->caps.max_mtu) ||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
* Copyright (c) 2018 Hisilicon Limited.
|
||||
*/
|
||||
|
||||
#include <linux/pci.h>
|
||||
#include <rdma/ib_umem.h>
|
||||
#include <rdma/uverbs_ioctl.h>
|
||||
#include "hns_roce_device.h"
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user