Skip to content

Commit 50174a7

Browse files
Eli Cohendledford
authored andcommitted
IB/core: Add interfaces to control VF attributes
Following the practice exercised for network devices which allow the PF net device to configure attributes of its virtual functions, we introduce the following functions to be used by IPoIB which is the network driver implementation for IB devices. ib_set_vf_link_state - set the policy for a VF link. More below. ib_get_vf_config - read configuration information of a VF ib_get_vf_stats - read VF statistics ib_set_vf_guid - set the node or port GUID of a VF Also add an indication in the device cap flags that indicates that this IB devices is based on a virtual function. A VF shares the physical port with the PF and other VFs. When setting the link state we have three options: 1. Auto - in this mode, the virtual port follows the state of the physical port and becomes active only if the physical port's state is active. In all other cases it remains in a Down state. 2. Down - sets the state of the virtual port to Down 3. Up - causes the virtual port to transition into Initialize state if it was not already in this state. A virtualization aware subnet manager can then bring the state of the port into the Active state. Signed-off-by: Eli Cohen <eli@mellanox.com> Reviewed-by: Or Gerlitz <ogerlitz@mellanox.com> Signed-off-by: Doug Ledford <dledford@redhat.com>
1 parent a0c1b2a commit 50174a7

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed

drivers/infiniband/core/verbs.c

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1551,6 +1551,46 @@ int ib_check_mr_status(struct ib_mr *mr, u32 check_mask,
15511551
}
15521552
EXPORT_SYMBOL(ib_check_mr_status);
15531553

1554+
int ib_set_vf_link_state(struct ib_device *device, int vf, u8 port,
1555+
int state)
1556+
{
1557+
if (!device->set_vf_link_state)
1558+
return -ENOSYS;
1559+
1560+
return device->set_vf_link_state(device, vf, port, state);
1561+
}
1562+
EXPORT_SYMBOL(ib_set_vf_link_state);
1563+
1564+
int ib_get_vf_config(struct ib_device *device, int vf, u8 port,
1565+
struct ifla_vf_info *info)
1566+
{
1567+
if (!device->get_vf_config)
1568+
return -ENOSYS;
1569+
1570+
return device->get_vf_config(device, vf, port, info);
1571+
}
1572+
EXPORT_SYMBOL(ib_get_vf_config);
1573+
1574+
int ib_get_vf_stats(struct ib_device *device, int vf, u8 port,
1575+
struct ifla_vf_stats *stats)
1576+
{
1577+
if (!device->get_vf_stats)
1578+
return -ENOSYS;
1579+
1580+
return device->get_vf_stats(device, vf, port, stats);
1581+
}
1582+
EXPORT_SYMBOL(ib_get_vf_stats);
1583+
1584+
int ib_set_vf_guid(struct ib_device *device, int vf, u8 port, u64 guid,
1585+
int type)
1586+
{
1587+
if (!device->set_vf_guid)
1588+
return -ENOSYS;
1589+
1590+
return device->set_vf_guid(device, vf, port, guid, type);
1591+
}
1592+
EXPORT_SYMBOL(ib_set_vf_guid);
1593+
15541594
/**
15551595
* ib_map_mr_sg() - Map the largest prefix of a dma mapped SG list
15561596
* and set it the memory region.

include/rdma/ib_verbs.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
#include <linux/string.h>
5757
#include <linux/slab.h>
5858

59+
#include <linux/if_link.h>
5960
#include <linux/atomic.h>
6061
#include <linux/mmu_notifier.h>
6162
#include <asm/uaccess.h>
@@ -218,6 +219,7 @@ enum ib_device_cap_flags {
218219
IB_DEVICE_SIGNATURE_HANDOVER = (1 << 30),
219220
IB_DEVICE_ON_DEMAND_PAGING = (1 << 31),
220221
IB_DEVICE_SG_GAPS_REG = (1ULL << 32),
222+
IB_DEVICE_VIRTUAL_FUNCTION = ((u64)1 << 33),
221223
};
222224

223225
enum ib_signature_prot_cap {
@@ -1867,6 +1869,14 @@ struct ib_device {
18671869
void (*disassociate_ucontext)(struct ib_ucontext *ibcontext);
18681870
void (*drain_rq)(struct ib_qp *qp);
18691871
void (*drain_sq)(struct ib_qp *qp);
1872+
int (*set_vf_link_state)(struct ib_device *device, int vf, u8 port,
1873+
int state);
1874+
int (*get_vf_config)(struct ib_device *device, int vf, u8 port,
1875+
struct ifla_vf_info *ivf);
1876+
int (*get_vf_stats)(struct ib_device *device, int vf, u8 port,
1877+
struct ifla_vf_stats *stats);
1878+
int (*set_vf_guid)(struct ib_device *device, int vf, u8 port, u64 guid,
1879+
int type);
18701880

18711881
struct ib_dma_mapping_ops *dma_ops;
18721882

@@ -2310,6 +2320,15 @@ int ib_query_gid(struct ib_device *device,
23102320
u8 port_num, int index, union ib_gid *gid,
23112321
struct ib_gid_attr *attr);
23122322

2323+
int ib_set_vf_link_state(struct ib_device *device, int vf, u8 port,
2324+
int state);
2325+
int ib_get_vf_config(struct ib_device *device, int vf, u8 port,
2326+
struct ifla_vf_info *info);
2327+
int ib_get_vf_stats(struct ib_device *device, int vf, u8 port,
2328+
struct ifla_vf_stats *stats);
2329+
int ib_set_vf_guid(struct ib_device *device, int vf, u8 port, u64 guid,
2330+
int type);
2331+
23132332
int ib_query_pkey(struct ib_device *device,
23142333
u8 port_num, u16 index, u16 *pkey);
23152334

0 commit comments

Comments
 (0)