Skip to content

Commit 6d39786

Browse files
yishaihdledford
authored andcommitted
IB/core: Introduce Receive Work Queue indirection table
Introduce Receive Work Queue (WQ) indirection table. This object can be used to spread incoming traffic to different receive Work Queues. A Receive WQ indirection table points to variable size of WQs. This table is given to a QP in downstream patches. Signed-off-by: Yishai Hadas <[email protected]> Signed-off-by: Matan Barak <[email protected]> Reviewed-by: Sagi Grimberg <[email protected]> Signed-off-by: Doug Ledford <[email protected]>
1 parent 79b20a6 commit 6d39786

File tree

2 files changed

+85
-0
lines changed

2 files changed

+85
-0
lines changed

drivers/infiniband/core/verbs.c

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1636,6 +1636,68 @@ int ib_modify_wq(struct ib_wq *wq, struct ib_wq_attr *wq_attr,
16361636
}
16371637
EXPORT_SYMBOL(ib_modify_wq);
16381638

1639+
/*
1640+
* ib_create_rwq_ind_table - Creates a RQ Indirection Table.
1641+
* @device: The device on which to create the rwq indirection table.
1642+
* @ib_rwq_ind_table_init_attr: A list of initial attributes required to
1643+
* create the Indirection Table.
1644+
*
1645+
* Note: The life time of ib_rwq_ind_table_init_attr->ind_tbl is not less
1646+
* than the created ib_rwq_ind_table object and the caller is responsible
1647+
* for its memory allocation/free.
1648+
*/
1649+
struct ib_rwq_ind_table *ib_create_rwq_ind_table(struct ib_device *device,
1650+
struct ib_rwq_ind_table_init_attr *init_attr)
1651+
{
1652+
struct ib_rwq_ind_table *rwq_ind_table;
1653+
int i;
1654+
u32 table_size;
1655+
1656+
if (!device->create_rwq_ind_table)
1657+
return ERR_PTR(-ENOSYS);
1658+
1659+
table_size = (1 << init_attr->log_ind_tbl_size);
1660+
rwq_ind_table = device->create_rwq_ind_table(device,
1661+
init_attr, NULL);
1662+
if (IS_ERR(rwq_ind_table))
1663+
return rwq_ind_table;
1664+
1665+
rwq_ind_table->ind_tbl = init_attr->ind_tbl;
1666+
rwq_ind_table->log_ind_tbl_size = init_attr->log_ind_tbl_size;
1667+
rwq_ind_table->device = device;
1668+
rwq_ind_table->uobject = NULL;
1669+
atomic_set(&rwq_ind_table->usecnt, 0);
1670+
1671+
for (i = 0; i < table_size; i++)
1672+
atomic_inc(&rwq_ind_table->ind_tbl[i]->usecnt);
1673+
1674+
return rwq_ind_table;
1675+
}
1676+
EXPORT_SYMBOL(ib_create_rwq_ind_table);
1677+
1678+
/*
1679+
* ib_destroy_rwq_ind_table - Destroys the specified Indirection Table.
1680+
* @wq_ind_table: The Indirection Table to destroy.
1681+
*/
1682+
int ib_destroy_rwq_ind_table(struct ib_rwq_ind_table *rwq_ind_table)
1683+
{
1684+
int err, i;
1685+
u32 table_size = (1 << rwq_ind_table->log_ind_tbl_size);
1686+
struct ib_wq **ind_tbl = rwq_ind_table->ind_tbl;
1687+
1688+
if (atomic_read(&rwq_ind_table->usecnt))
1689+
return -EBUSY;
1690+
1691+
err = rwq_ind_table->device->destroy_rwq_ind_table(rwq_ind_table);
1692+
if (!err) {
1693+
for (i = 0; i < table_size; i++)
1694+
atomic_dec(&ind_tbl[i]->usecnt);
1695+
}
1696+
1697+
return err;
1698+
}
1699+
EXPORT_SYMBOL(ib_destroy_rwq_ind_table);
1700+
16391701
struct ib_flow *ib_create_flow(struct ib_qp *qp,
16401702
struct ib_flow_attr *flow_attr,
16411703
int domain)

include/rdma/ib_verbs.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1473,6 +1473,21 @@ struct ib_wq_attr {
14731473
enum ib_wq_state curr_wq_state;
14741474
};
14751475

1476+
struct ib_rwq_ind_table {
1477+
struct ib_device *device;
1478+
struct ib_uobject *uobject;
1479+
atomic_t usecnt;
1480+
u32 ind_tbl_num;
1481+
u32 log_ind_tbl_size;
1482+
struct ib_wq **ind_tbl;
1483+
};
1484+
1485+
struct ib_rwq_ind_table_init_attr {
1486+
u32 log_ind_tbl_size;
1487+
/* Each entry is a pointer to Receive Work Queue */
1488+
struct ib_wq **ind_tbl;
1489+
};
1490+
14761491
struct ib_qp {
14771492
struct ib_device *device;
14781493
struct ib_pd *pd;
@@ -1974,6 +1989,10 @@ struct ib_device {
19741989
struct ib_wq_attr *attr,
19751990
u32 wq_attr_mask,
19761991
struct ib_udata *udata);
1992+
struct ib_rwq_ind_table * (*create_rwq_ind_table)(struct ib_device *device,
1993+
struct ib_rwq_ind_table_init_attr *init_attr,
1994+
struct ib_udata *udata);
1995+
int (*destroy_rwq_ind_table)(struct ib_rwq_ind_table *wq_ind_table);
19771996
struct ib_dma_mapping_ops *dma_ops;
19781997

19791998
struct module *owner;
@@ -3224,6 +3243,10 @@ struct ib_wq *ib_create_wq(struct ib_pd *pd,
32243243
int ib_destroy_wq(struct ib_wq *wq);
32253244
int ib_modify_wq(struct ib_wq *wq, struct ib_wq_attr *attr,
32263245
u32 wq_attr_mask);
3246+
struct ib_rwq_ind_table *ib_create_rwq_ind_table(struct ib_device *device,
3247+
struct ib_rwq_ind_table_init_attr*
3248+
wq_ind_table_init_attr);
3249+
int ib_destroy_rwq_ind_table(struct ib_rwq_ind_table *wq_ind_table);
32273250

32283251
int ib_map_mr_sg(struct ib_mr *mr, struct scatterlist *sg, int sg_nents,
32293252
unsigned int *sg_offset, unsigned int page_size);

0 commit comments

Comments
 (0)