Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Junxian Huang and committed by
Leon Romanovsky
cdb3a6f1 04e031ff

+25 -14
-1
drivers/infiniband/hw/hns/hns_roce_ah.c
··· 30 30 * SOFTWARE. 31 31 */ 32 32 33 - #include <linux/pci.h> 34 33 #include <rdma/ib_addr.h> 35 34 #include <rdma/ib_cache.h> 36 35 #include "hns_roce_device.h"
+12
drivers/infiniband/hw/hns/hns_roce_device.h
··· 33 33 #ifndef _HNS_ROCE_DEVICE_H 34 34 #define _HNS_ROCE_DEVICE_H 35 35 36 + #include <linux/pci.h> 36 37 #include <rdma/ib_verbs.h> 37 38 #include <rdma/hns-abi.h> 38 39 #include "hns_roce_debugfs.h" ··· 1164 1163 { 1165 1164 return grh->sgid_attr->gid_type == IB_GID_TYPE_ROCE_UDP_ENCAP ? 1166 1165 grh->traffic_class >> DSCP_SHIFT : grh->traffic_class; 1166 + } 1167 + 1168 + static inline struct net_device *get_hr_netdev(struct hns_roce_dev *hr_dev, 1169 + u8 port) 1170 + { 1171 + return hr_dev->iboe.netdevs[port]; 1172 + } 1173 + 1174 + static inline u8 get_hr_bus_num(struct hns_roce_dev *hr_dev) 1175 + { 1176 + return hr_dev->pci_dev->bus->number; 1167 1177 } 1168 1178 1169 1179 void hns_roce_init_uar_table(struct hns_roce_dev *dev);
+10 -9
drivers/infiniband/hw/hns/hns_roce_main.c
··· 32 32 */ 33 33 #include <linux/acpi.h> 34 34 #include <linux/module.h> 35 - #include <linux/pci.h> 36 35 #include <rdma/ib_addr.h> 37 36 #include <rdma/ib_smi.h> 38 37 #include <rdma/ib_user_verbs.h> ··· 147 148 148 149 static int hns_roce_setup_mtu_mac(struct hns_roce_dev *hr_dev) 149 150 { 151 + struct net_device *net_dev; 150 152 int ret; 151 153 u8 i; 152 154 153 155 for (i = 0; i < hr_dev->caps.num_ports; i++) { 154 - ret = hns_roce_set_mac(hr_dev, i, 155 - hr_dev->iboe.netdevs[i]->dev_addr); 156 + net_dev = get_hr_netdev(hr_dev, i); 157 + ret = hns_roce_set_mac(hr_dev, i, net_dev->dev_addr); 156 158 if (ret) 157 159 return ret; 158 160 } ··· 246 246 247 247 spin_lock_irqsave(&hr_dev->iboe.lock, flags); 248 248 249 - net_dev = hr_dev->iboe.netdevs[port]; 249 + net_dev = get_hr_netdev(hr_dev, port); 250 250 if (!net_dev) { 251 251 spin_unlock_irqrestore(&hr_dev->iboe.lock, flags); 252 252 dev_err(dev, "find netdev %u failed!\n", port); ··· 704 704 705 705 static int hns_roce_register_device(struct hns_roce_dev *hr_dev) 706 706 { 707 - int ret; 708 707 struct hns_roce_ib_iboe *iboe = NULL; 709 - struct ib_device *ib_dev = NULL; 710 708 struct device *dev = hr_dev->dev; 709 + struct ib_device *ib_dev = NULL; 710 + struct net_device *net_dev; 711 711 unsigned int i; 712 + int ret; 712 713 713 714 iboe = &hr_dev->iboe; 714 715 spin_lock_init(&iboe->lock); ··· 745 744 ib_set_device_ops(ib_dev, &hns_roce_dev_ops); 746 745 ib_set_device_ops(ib_dev, &hns_roce_dev_restrack_ops); 747 746 for (i = 0; i < hr_dev->caps.num_ports; i++) { 748 - if (!hr_dev->iboe.netdevs[i]) 747 + net_dev = get_hr_netdev(hr_dev, i); 748 + if (!net_dev) 749 749 continue; 750 750 751 - ret = ib_device_set_netdev(ib_dev, hr_dev->iboe.netdevs[i], 752 - i + 1); 751 + ret = ib_device_set_netdev(ib_dev, net_dev, i + 1); 753 752 if (ret) 754 753 return ret; 755 754 }
-1
drivers/infiniband/hw/hns/hns_roce_pd.c
··· 30 30 * SOFTWARE. 31 31 */ 32 32 33 - #include <linux/pci.h> 34 33 #include "hns_roce_device.h" 35 34 36 35 void hns_roce_init_pd_table(struct hns_roce_dev *hr_dev)
+3 -2
drivers/infiniband/hw/hns/hns_roce_qp.c
··· 31 31 * SOFTWARE. 32 32 */ 33 33 34 - #include <linux/pci.h> 35 34 #include <rdma/ib_addr.h> 36 35 #include <rdma/ib_umem.h> 37 36 #include <rdma/uverbs_ioctl.h> ··· 1349 1350 struct hns_roce_qp *hr_qp, 1350 1351 struct ib_qp_attr *attr, int attr_mask) 1351 1352 { 1353 + struct net_device *net_dev; 1352 1354 enum ib_mtu active_mtu; 1353 1355 int p; 1354 1356 1355 1357 p = attr_mask & IB_QP_PORT ? (attr->port_num - 1) : hr_qp->port; 1356 - active_mtu = iboe_get_mtu(hr_dev->iboe.netdevs[p]->mtu); 1358 + net_dev = get_hr_netdev(hr_dev, p); 1359 + active_mtu = iboe_get_mtu(net_dev->mtu); 1357 1360 1358 1361 if ((hr_dev->caps.max_mtu >= IB_MTU_2048 && 1359 1362 attr->path_mtu > hr_dev->caps.max_mtu) ||
-1
drivers/infiniband/hw/hns/hns_roce_srq.c
··· 3 3 * Copyright (c) 2018 Hisilicon Limited. 4 4 */ 5 5 6 - #include <linux/pci.h> 7 6 #include <rdma/ib_umem.h> 8 7 #include <rdma/uverbs_ioctl.h> 9 8 #include "hns_roce_device.h"