small cleanup - use PCI lib
cover small cleanup - use PCI lib
Some drivers could use more the PCI lib facilities.
Thomas Monjalon (2):
drivers: use macro for PCI address format
drivers: use function to compare PCI addresses
drivers/event/skeleton/skeleton_eventdev.c | 2 +- drivers/net/ena/ena_ethdev.c | 2 +- drivers/net/enic/enic.h | 3 +-- drivers/net/enic/enic_ethdev.c | 2 +- drivers/net/enic/enic_vf_representor.c | 2 +- drivers/net/hinic/hinic_pmd_ethdev.c | 4 ++-- drivers/net/mana/mana.c | 6 ++---- drivers/net/mlx4/mlx4.c | 5 +---- drivers/net/mlx5/linux/mlx5_os.c | 7 ++----- drivers/net/thunderx/nicvf_ethdev.c | 2 +- 10 files changed, 13 insertions(+), 22 deletions(-)
Signature · 1 line
2.42.0
PATCH 1/2 drivers: use macro for PCI address format
Some places were not using the macro PCI_PRI_FMT
as print format of a PCI address.
Note: RTE prefix is missing in the name of some PCI macros.
--- drivers/event/skeleton/skeleton_eventdev.c | 2 +- drivers/net/ena/ena_ethdev.c | 2 +- drivers/net/enic/enic.h | 3 +-- drivers/net/enic/enic_ethdev.c | 2 +- drivers/net/enic/enic_vf_representor.c | 2 +- drivers/net/hinic/hinic_pmd_ethdev.c | 4 ++-- drivers/net/mlx5/linux/mlx5_os.c | 2 +- drivers/net/thunderx/nicvf_ethdev.c | 2 +- 8 files changed, 9 insertions(+), 10 deletions(-)
drivers/event/skeleton/skeleton_eventdev.c +1 -1
@@ -373,7 +373,7 @@ skeleton_eventdev_init(struct rte_eventdev *eventdev) skel->subsystem_device_id = pci_dev->id.subsystem_device_id; skel->subsystem_vendor_id = pci_dev->id.subsystem_vendor_id; -PMD_DRV_LOG (DEBUG ,"pci device (%x:%x) %u:%u:%u:%u" , +PMD_DRV_LOG (DEBUG ,"PCI device (%x:%x) " PCI_PRI_FMT , pci_dev->id.vendor_id, pci_dev->id.device_id, pci_dev->addr.domain, pci_dev->addr.bus, pci_dev->addr.devid, pci_dev->addr.function);
drivers/net/ena/ena_ethdev.c +1 -1
@@ -2125,7 +2125,7 @@ static int eth_ena_dev_init(struct rte_eth_dev *eth_dev) pci_dev =RTE_ETH_DEV_TO_PCI (eth_dev); - PMD_INIT_LOG(INFO, "Initializing %x:%x:%x.%d\n", + PMD_INIT_LOG(INFO, "Initializing " PCI_PRI_FMT "\n", pci_dev->addr.domain, pci_dev->addr.bus, pci_dev->addr.devid,
drivers/net/enic/enic.h +1 -2
@@ -32,7 +32,6 @@#define ENICPMD_SETTING (enic, f) ((enic->config.flags & VENETF_##f) ? 1 : 0) -#define ENICPMD_BDF_LENGTH 13/* 0000:00:00.0'\0' */ #define ENIC_CALC_IP_CKSUM 1#define ENIC_CALC_TCP_UDP_CKSUM 2#define ENIC_MAX_MTU 9000
@@ -101,7 +100,7 @@ struct enic {bool overlay_offload;struct rte_eth_dev *rte_dev;struct rte_eth_dev_data *dev_data; -char bdf_name[ENICPMD_BDF_LENGTH ]; +char bdf_name[PCI_PRI_STR_SIZE ];int dev_fd;int iommu_group_fd;int iommu_groupid;
drivers/net/enic/enic_ethdev.c +1 -1
@@ -1274,7 +1274,7 @@ static int eth_enic_dev_init(struct rte_eth_dev *eth_dev, enic->pdev = pdev; addr = &pdev->addr; -snprintf (enic->bdf_name,ENICPMD_BDF_LENGTH ,"%04x:%02x:%02x.%x" , +snprintf (enic->bdf_name,PCI_PRI_STR_SIZE ,PCI_PRI_FMT , addr->domain, addr->bus, addr->devid, addr->function); err =enic_check_devargs (eth_dev);
drivers/net/enic/enic_vf_representor.c +1 -1
@@ -707,7 +707,7 @@ int enic_vf_representor_init(struct rte_eth_dev *eth_dev, void *init_params)LIST_INIT (&vf_enic->memzone_list);rte_spinlock_init (&vf_enic->memzone_list_lock); addr = &vf->bdf; -snprintf (vf_enic->bdf_name,ENICPMD_BDF_LENGTH ,"%04x:%02x:%02x.%x" , +snprintf (vf_enic->bdf_name,PCI_PRI_STR_SIZE ,PCI_PRI_FMT , addr->domain, addr->bus, addr->devid, addr->function);return 0 ; }
drivers/net/hinic/hinic_pmd_ethdev.c +2 -2
@@ -3086,7 +3086,7 @@ static int hinic_func_init(struct rte_eth_dev *eth_dev)snprintf (nic_dev->proc_dev_name,sizeof (nic_dev->proc_dev_name), -"hinic-%.4x:%.2x:%.2x.%x" , +"hinic-" PCI_PRI_FMT , pci_dev->addr.domain, pci_dev->addr.bus, pci_dev->addr.devid, pci_dev->addr.function);
@@ -3202,7 +3202,7 @@ static int hinic_dev_init(struct rte_eth_dev *eth_dev) pci_dev =RTE_ETH_DEV_TO_PCI (eth_dev); - PMD_DRV_LOG(INFO, "Initializing pf hinic-%.4x:%.2x:%.2x.%x in %s process", + PMD_DRV_LOG(INFO, "Initializing pf hinic-" PCI_PRI_FMT " in %s process", pci_dev->addr.domain, pci_dev->addr.bus, pci_dev->addr.devid, pci_dev->addr.function, (rte_eal_process_type() == RTE_PROC_PRIMARY) ?
drivers/net/mlx5/linux/mlx5_os.c +1 -1
@@ -1952,7 +1952,7 @@ mlx5_device_bond_pci_match(const char *ibdev_name, ifindex, bond_info->ifindex, bond_info->ifname); }if (owner ==0 && pf !=0 ) { -DRV_LOG (INFO ,"PCIe instance %04x:%02x:%02x.%x isn't bonding owner" , +DRV_LOG (INFO ,"PCIe instance " PCI_PRI_FMT " isn't bonding owner" , pci_dev->domain, pci_dev->bus, pci_dev->devid, pci_dev->function); }
drivers/net/thunderx/nicvf_ethdev.c +1 -1
@@ -2218,7 +2218,7 @@ nicvf_eth_dev_init(struct rte_eth_dev *eth_dev) nic->subsystem_device_id = pci_dev->id.subsystem_device_id; nic->subsystem_vendor_id = pci_dev->id.subsystem_vendor_id; -PMD_INIT_LOG (DEBUG ,"nicvf: device (%x:%x) %u:%u:%u:%u" , +PMD_INIT_LOG (DEBUG ,"nicvf: device (%x:%x) " PCI_PRI_FMT , pci_dev->id.vendor_id, pci_dev->id.device_id, pci_dev->addr.domain, pci_dev->addr.bus, pci_dev->addr.devid, pci_dev->addr.function);
Signature · 1 line
2.42.0
Re: [PATCH 1/2] drivers: use macro for PCI address format
From: Thomas Monjalon <[email protected]>
Date: Thursday, October 19, 2023 at 8:41 AM
To: [email protected] <[email protected]>
Cc: David Marchand <[email protected]>, [email protected] <[email protected]>, Jerin Jacob <[email protected]>, Michal Krawczyk <[email protected]>, Shai Brandes <[email protected]>, Evgeny Schemeilin <[email protected]>, Igor Chauskin <[email protected]>, Ron Beider <[email protected]>, John Daley (johndale) <[email protected]>, Hyong Youb Kim (hyonkim) <[email protected]>, Ziyang Xuan <[email protected]>, Xiaoyun Wang <[email protected]>, Guoyang Zhou <[email protected]>, Matan Azrad <[email protected]>, Viacheslav Ovsiienko <[email protected]>, Ori Kam <[email protected]>, Suanming Mou <[email protected]>, Maciej Czekaj <[email protected]>
Subject: [PATCH 1/2] drivers: use macro for PCI address format
Some places were not using the macro PCI_PRI_FMT
as print format of a PCI address.
Note: RTE prefix is missing in the name of some PCI macros.
--- drivers/event/skeleton/skeleton_eventdev.c | 2 +- drivers/net/ena/ena_ethdev.c | 2 +- drivers/net/enic/enic.h | 3 +-- drivers/net/enic/enic_ethdev.c | 2 +- drivers/net/enic/enic_vf_representor.c | 2 +- drivers/net/hinic/hinic_pmd_ethdev.c | 4 ++-- drivers/net/mlx5/linux/mlx5_os.c | 2 +- drivers/net/thunderx/nicvf_ethdev.c | 2 +- 8 files changed, 9 insertions(+), 10 deletions(-)
drivers/event/skeleton/skeleton_eventdev.c +1 -1
@@ -373,7 +373,7 @@ skeleton_eventdev_init(struct rte_eventdev *eventdev) skel->subsystem_device_id = pci_dev->id.subsystem_device_id; skel->subsystem_vendor_id = pci_dev->id.subsystem_vendor_id; -PMD_DRV_LOG (DEBUG ,"pci device (%x:%x) %u:%u:%u:%u" , +PMD_DRV_LOG (DEBUG ,"PCI device (%x:%x) " PCI_PRI_FMT , pci_dev->id.vendor_id, pci_dev->id.device_id, pci_dev->addr.domain, pci_dev->addr.bus, pci_dev->addr.devid, pci_dev->addr.function);
drivers/net/ena/ena_ethdev.c +1 -1
@@ -2125,7 +2125,7 @@ static int eth_ena_dev_init(struct rte_eth_dev *eth_dev) pci_dev =RTE_ETH_DEV_TO_PCI (eth_dev); - PMD_INIT_LOG(INFO, "Initializing %x:%x:%x.%d\n", + PMD_INIT_LOG(INFO, "Initializing " PCI_PRI_FMT "\n", pci_dev->addr.domain, pci_dev->addr.bus, pci_dev->addr.devid,
drivers/net/enic/enic.h +1 -2
@@ -32,7 +32,6 @@#define ENICPMD_SETTING (enic, f) ((enic->config.flags & VENETF_##f) ? 1 : 0) -#define ENICPMD_BDF_LENGTH 13/* 0000:00:00.0'\0' */ #define ENIC_CALC_IP_CKSUM 1#define ENIC_CALC_TCP_UDP_CKSUM 2#define ENIC_MAX_MTU 9000
@@ -101,7 +100,7 @@ struct enic {bool overlay_offload;struct rte_eth_dev *rte_dev;struct rte_eth_dev_data *dev_data; -char bdf_name[ENICPMD_BDF_LENGTH ]; +char bdf_name[PCI_PRI_STR_SIZE ];int dev_fd;int iommu_group_fd;int iommu_groupid;
drivers/net/enic/enic_ethdev.c +1 -1
@@ -1274,7 +1274,7 @@ static int eth_enic_dev_init(struct rte_eth_dev *eth_dev, enic->pdev = pdev; addr = &pdev->addr; -snprintf (enic->bdf_name,ENICPMD_BDF_LENGTH ,"%04x:%02x:%02x.%x" , +snprintf (enic->bdf_name,PCI_PRI_STR_SIZE ,PCI_PRI_FMT , addr->domain, addr->bus, addr->devid, addr->function); err =enic_check_devargs (eth_dev);
drivers/net/enic/enic_vf_representor.c +1 -1
@@ -707,7 +707,7 @@ int enic_vf_representor_init(struct rte_eth_dev *eth_dev, void *init_params)LIST_INIT (&vf_enic->memzone_list);rte_spinlock_init (&vf_enic->memzone_list_lock); addr = &vf->bdf; -snprintf (vf_enic->bdf_name,ENICPMD_BDF_LENGTH ,"%04x:%02x:%02x.%x" , +snprintf (vf_enic->bdf_name,PCI_PRI_STR_SIZE ,PCI_PRI_FMT , addr->domain, addr->bus, addr->devid, addr->function);return 0 ; }
drivers/net/hinic/hinic_pmd_ethdev.c +2 -2
@@ -3086,7 +3086,7 @@ static int hinic_func_init(struct rte_eth_dev *eth_dev)snprintf (nic_dev->proc_dev_name,sizeof (nic_dev->proc_dev_name), -"hinic-%.4x:%.2x:%.2x.%x" , +"hinic-" PCI_PRI_FMT , pci_dev->addr.domain, pci_dev->addr.bus, pci_dev->addr.devid, pci_dev->addr.function);
@@ -3202,7 +3202,7 @@ static int hinic_dev_init(struct rte_eth_dev *eth_dev) pci_dev =RTE_ETH_DEV_TO_PCI (eth_dev); - PMD_DRV_LOG(INFO, "Initializing pf hinic-%.4x:%.2x:%.2x.%x in %s process", + PMD_DRV_LOG(INFO, "Initializing pf hinic-" PCI_PRI_FMT " in %s process", pci_dev->addr.domain, pci_dev->addr.bus, pci_dev->addr.devid, pci_dev->addr.function, (rte_eal_process_type() == RTE_PROC_PRIMARY) ?
drivers/net/mlx5/linux/mlx5_os.c +1 -1
@@ -1952,7 +1952,7 @@ mlx5_device_bond_pci_match(const char *ibdev_name, ifindex, bond_info->ifindex, bond_info->ifname); }if (owner ==0 && pf !=0 ) { -DRV_LOG (INFO ,"PCIe instance %04x:%02x:%02x.%x isn't bonding owner" , +DRV_LOG (INFO ,"PCIe instance " PCI_PRI_FMT " isn't bonding owner" , pci_dev->domain, pci_dev->bus, pci_dev->devid, pci_dev->function); }
drivers/net/thunderx/nicvf_ethdev.c +1 -1
@@ -2218,7 +2218,7 @@ nicvf_eth_dev_init(struct rte_eth_dev *eth_dev) nic->subsystem_device_id = pci_dev->id.subsystem_device_id; nic->subsystem_vendor_id = pci_dev->id.subsystem_vendor_id; -PMD_INIT_LOG (DEBUG ,"nicvf: device (%x:%x) %u:%u:%u:%u" , +PMD_INIT_LOG (DEBUG ,"nicvf: device (%x:%x) " PCI_PRI_FMT , pci_dev->id.vendor_id, pci_dev->id.device_id, pci_dev->addr.domain, pci_dev->addr.bus, pci_dev->addr.devid, pci_dev->addr.function);
--
2.42.0
lihuisong (C)
Acked-byRe: [PATCH 1/2] drivers: use macro for PCI address format
lgtm,
Quoted 160 lines · John Daley (johndale)
Acked-by John Daley <[email protected]>*From: *Thomas Monjalon <[email protected]>
*Date: *Thursday, October 19, 2023 at 8:41 AM
*To: *[email protected] <[email protected]>
*Cc: *David Marchand <[email protected]>, [email protected] <[email protected]>, Jerin Jacob <[email protected]>, Michal Krawczyk <[email protected]>, Shai Brandes <[email protected]>, Evgeny Schemeilin <[email protected]>, Igor Chauskin <[email protected]>, Ron Beider <[email protected]>, John Daley (johndale) <[email protected]>, Hyong Youb Kim (hyonkim) <[email protected]>, Ziyang Xuan <[email protected]>, Xiaoyun Wang <[email protected]>, Guoyang Zhou <[email protected]>, Matan Azrad <[email protected]>, Viacheslav Ovsiienko <[email protected]>, Ori Kam <[email protected]>, Suanming Mou <[email protected]>, Maciej Czekaj <[email protected]> *Subject: *[PATCH 1/2] drivers: use macro for PCI address formatSome places were not using the macro
PCI_PRI_FMT
as print format of a PCI address.Note: RTE prefix is missing in the name of some PCI macros.
Signed-off-by Thomas Monjalon <[email protected]>---
drivers/event/skeleton/skeleton_eventdev.c | 2 +- drivers/net/ena/ena_ethdev.c | 2 +- drivers/net/enic/enic.h | 3 +-- drivers/net/enic/enic_ethdev.c | 2 +- drivers/net/enic/enic_vf_representor.c | 2 +- drivers/net/hinic/hinic_pmd_ethdev.c | 4 ++-- drivers/net/mlx5/linux/mlx5_os.c | 2 +- drivers/net/thunderx/nicvf_ethdev.c | 2 +-8 files changed, 9 insertions(+), 10 deletions(-)drivers/event/skeleton/skeleton_eventdev.c +1
-1@@ -373,7 +373,7 @@ skeleton_eventdev_init(struct rte_eventdev *eventdev) skel->subsystem_device_id = pci_dev->id.subsystem_device_id; skel->subsystem_vendor_id = pci_dev->id.subsystem_vendor_id; - PMD_DRV_LOG(DEBUG, "pci device (%x:%x) %u:%u:%u:%u", + PMD_DRV_LOG(DEBUG, "PCI device (%x:%x) " PCI_PRI_FMT, pci_dev->id.vendor_id, pci_dev->id.device_id, pci_dev->addr.domain, pci_dev->addr.bus, pci_dev->addr.devid, pci_dev->addr.function);drivers/net/ena/ena_ethdev.c +1
-1@@ -2125,7 +2125,7 @@ static int eth_ena_dev_init(struct rte_eth_dev *eth_dev) pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev); - PMD_INIT_LOG(INFO, "Initializing %x:%x:%x.%d\n", + PMD_INIT_LOG(INFO, "Initializing " PCI_PRI_FMT "\n", pci_dev->addr.domain, pci_dev->addr.bus,
pci_dev->addr.devid,drivers/net/enic/enic.h +1
-2@@ -32,7 +32,6 @@ #define ENICPMD_SETTING(enic, f) ((enic->config.flags & VENETF_##f) ? 1 : 0) -#define ENICPMD_BDF_LENGTH 13/* 0000:00:00.0'\0' */ #define ENIC_CALC_IP_CKSUM 1 #define ENIC_CALC_TCP_UDP_CKSUM 2 #define ENIC_MAX_MTU 9000@@ -101,7 +100,7 @@ struct enic { bool overlay_offload; struct rte_eth_dev *rte_dev; struct rte_eth_dev_data *dev_data; - char bdf_name[ENICPMD_BDF_LENGTH]; + char bdf_name[PCI_PRI_STR_SIZE]; int dev_fd; int iommu_group_fd; int iommu_groupid;drivers/net/enic/enic_ethdev.c +1
-1@@ -1274,7 +1274,7 @@ static int eth_enic_dev_init(struct rte_eth_dev *eth_dev, enic->pdev = pdev; addr = &pdev->addr; - snprintf(enic->bdf_name, ENICPMD_BDF_LENGTH, "%04x:%02x:%02x.%x", + snprintf(enic->bdf_name, PCI_PRI_STR_SIZE, PCI_PRI_FMT, addr->domain, addr->bus, addr->devid, addr->function);err =
enic_check_devargs(eth_dev);drivers/net/enic/enic_vf_representor.c +1
-1@@ -707,7 +707,7 @@ int enic_vf_representor_init(struct rte_eth_dev *eth_dev, void *init_params) LIST_INIT(&vf_enic->memzone_list);rte_spinlock_init (&vf_enic->memzone_list_lock); addr = &vf->bdf; - snprintf(vf_enic->bdf_name, ENICPMD_BDF_LENGTH,"%04x:%02x:%02x.%x" , + snprintf(vf_enic->bdf_name, PCI_PRI_STR_SIZE, PCI_PRI_FMT, addr->domain, addr->bus, addr->devid, addr->function);return 0;
}drivers/net/hinic/hinic_pmd_ethdev.c +2
-2@@ -3086,7 +3086,7 @@ static int hinic_func_init(struct rte_eth_dev *eth_dev) snprintf(nic_dev->proc_dev_name, sizeof(nic_dev->proc_dev_name), - "hinic-%.4x:%.2x:%.2x.%x", + "hinic-" PCI_PRI_FMT, pci_dev->addr.domain, pci_dev->addr.bus, pci_dev->addr.devid, pci_dev->addr.function);@@ -3202,7 +3202,7 @@ static int hinic_dev_init(struct rte_eth_dev *eth_dev) pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev); - PMD_DRV_LOG(INFO, "Initializing pf hinic-%.4x:%.2x:%.2x.%x in %s process", + PMD_DRV_LOG(INFO, "Initializing pf hinic-" PCI_PRI_FMT " in %s process",
pci_dev->addr.domain,pci_dev->addr.bus,pci_dev->addr.devid,pci_dev->addr.function, (rte_eal_process_type()==RTE_PROC_PRIMARY) ?drivers/net/mlx5/linux/mlx5_os.c +1
-1@@ -1952,7 +1952,7 @@ mlx5_device_bond_pci_match(const char *ibdev_name, ifindex, bond_info->ifindex, bond_info->ifname); } if (owner == 0 && pf != 0) { - DRV_LOG(INFO, "PCIe instance %04x:%02x:%02x.%x isn't bonding owner", + DRV_LOG(INFO, "PCIe instance " PCI_PRI_FMT " isn't bonding owner", pci_dev->domain, pci_dev->bus, pci_dev->devid,
pci_dev->function);
}drivers/net/thunderx/nicvf_ethdev.c +1
-1@@ -2218,7 +2218,7 @@ nicvf_eth_dev_init(struct rte_eth_dev *eth_dev) nic->subsystem_device_id = pci_dev->id.subsystem_device_id; nic->subsystem_vendor_id = pci_dev->id.subsystem_vendor_id; - PMD_INIT_LOG(DEBUG, "nicvf: device (%x:%x) %u:%u:%u:%u", + PMD_INIT_LOG(DEBUG, "nicvf: device (%x:%x) " PCI_PRI_FMT, pci_dev->id.vendor_id, pci_dev->id.device_id, pci_dev->addr.domain, pci_dev->addr.bus, pci_dev->addr.devid, pci_dev->addr.function);Signature · 1 line
2.42.0
PATCH 2/2 drivers: use function to compare PCI addresses
In reply to Thomas MonjalonSome places were not using the function rte_pci_addr_cmp() to compare 2 PCI addresses.
--- drivers/net/mana/mana.c | 6 ++---- drivers/net/mlx4/mlx4.c | 5 +---- drivers/net/mlx5/linux/mlx5_os.c | 5 +---- 3 files changed, 4 insertions(+), 12 deletions(-)
drivers/net/mana/mana.c +2 -4
@@ -13,6 +13,7 @@#include <ethdev_pci.h> #include <rte_kvargs.h> #include <rte_eal_paging.h> +#include <rte_pci.h> #include <infiniband/verbs.h> #include <infiniband/manadv.h>
@@ -1464,10 +1465,7 @@ mana_pci_probe_mac(struct rte_pci_device *pci_dev,continue ;/* Ignore if this IB device is not this PCI device */ -if (pci_dev->addr.domain != pci_addr.domain || - pci_dev->addr.bus != pci_addr.bus || - pci_dev->addr.devid != pci_addr.devid || - pci_dev->addr.function != pci_addr.function) +if (rte_pci_addr_cmp (&pci_dev->addr, &pci_addr) !=0 )continue ; ctx =ibv_open_device (ibdev);
drivers/net/mlx4/mlx4.c +1 -4
@@ -817,10 +817,7 @@ mlx4_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)DEBUG ("checking device \"%s\"" , list[i]->name);if (mlx4_ibv_device_to_pci_addr (list[i], &pci_addr))continue ; -if ((pci_dev->addr.domain != pci_addr.domain) || - (pci_dev->addr.bus != pci_addr.bus) || - (pci_dev->addr.devid != pci_addr.devid) || - (pci_dev->addr.function != pci_addr.function)) +if (rte_pci_addr_cmp (&pci_dev->addr, &pci_addr) !=0 )continue ; vf = (pci_dev->id.device_id ==PCI_DEVICE_ID_MELLANOX_CONNECTX3VF );
drivers/net/mlx5/linux/mlx5_os.c +1 -4
@@ -2065,10 +2065,7 @@ mlx5_os_pci_probe_pf(struct mlx5_common_device *cdev,if (mlx5_get_pci_addr (ibv_list[ret]->ibdev_path, &pci_addr))continue ; -if (owner_pci.domain != pci_addr.domain || - owner_pci.bus != pci_addr.bus || - owner_pci.devid != pci_addr.devid || - owner_pci.function != pci_addr.function) +if (rte_pci_addr_cmp (&owner_pci, &pci_addr) !=0 )continue ;DRV_LOG (INFO ,"PCI information matches for device \"%s\"" , ibv_list[ret]->name);
Signature · 1 line
2.42.0
RE: [PATCH 2/2] drivers: use function to compare PCI addresses
Quoted 6 lines
Subject: [PATCH 2/2] drivers: use function to compare PCI addresses
Some places were not using the function
rte_pci_addr_cmp()to compare 2 PCI addresses.Signed-off-by Thomas Monjalon <[email protected]>
For MANA,
Quoted 68 lines
--- drivers/net/mana/mana.c | 6 ++---- drivers/net/mlx4/mlx4.c | 5 +---- drivers/net/mlx5/linux/mlx5_os.c | 5 +---- 3 files changed, 4 insertions(+), 12 deletions(-)drivers/net/mana/mana.c index renamed from drivers/net/mana/mana.c +0
-0
41c3cf2595..781ed76139100644drivers/net/mana/mana.c +2
-4@@ -13,6 +13,7 @@#include <ethdev_pci.h> #include <rte_kvargs.h> #include <rte_eal_paging.h> +#include <rte_pci.h> #include <infiniband/verbs.h> #include <infiniband/manadv.h> @@ -1464,10 +1465,7 @@ mana_pci_probe_mac(struct rte_pci_device *pci_dev, continue;/* Ignore if this IB device is not this PCI device */ -if (pci_dev->addr.domain != pci_addr.domain || - pci_dev->addr.bus != pci_addr.bus || - pci_dev->addr.devid != pci_addr.devid || - pci_dev->addr.function != pci_addr.function) +if (rte_pci_addr_cmp (&pci_dev->addr, &pci_addr) !=0 )continue ;drivers/net/mana/mana.c +0
-0ctx =ibv_open_device (ibdev);drivers/net/mlx4/mlx4.c index renamed from drivers/net/mlx4/mlx4.c +0
-0
1389b606cc..a1a7e93288100644drivers/net/mlx4/mlx4.c +1
-4@@ -817,10 +817,7 @@ mlx4_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev) DEBUG("checking device \"%s\"", list[i]->name);if (mlx4_ibv_device_to_pci_addr (list[i], &pci_addr))continue ; -if ((pci_dev->addr.domain != pci_addr.domain) || - (pci_dev->addr.bus != pci_addr.bus) || - (pci_dev->addr.devid != pci_addr.devid) || - (pci_dev->addr.function != pci_addr.function)) +if (rte_pci_addr_cmp (&pci_dev->addr, &pci_addr) !=0 )continue ; vf = (pci_dev->id.device_id ==drivers/net/mlx4/mlx4.c +0
-0PCI_DEVICE_ID_MELLANOX_CONNECTX3VF);drivers/net/mlx5/linux/mlx5_os.c +1
-4@@ -2065,10 +2065,7 @@ mlx5_os_pci_probe_pf(struct mlx5_common_device *cdev, if (mlx5_get_pci_addr(ibv_list[ret]->ibdev_path, &pci_addr)) continue; -if (owner_pci.domain != pci_addr.domain || - owner_pci.bus != pci_addr.bus || - owner_pci.devid != pci_addr.devid || - owner_pci.function != pci_addr.function) +if (rte_pci_addr_cmp (&owner_pci, &pci_addr) !=0 )continue ; DRV_LOG(INFO, "PCI information matches for device\"%s\"",
ibv_list[ret]->name);
--
2.42.0
Thomas Monjalon
Applied19/10/2023 17:31, Thomas Monjalon:
Quoted 5 lines
Some drivers could use more the PCI lib facilities.
Thomas Monjalon (2):
drivers: use macro for PCI address format
drivers: use function to compare PCI addresses
Applied