mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-22 17:01:14 +00:00
qed: simplify chain allocation with init params struct
To simplify qed_chain_alloc() prototype and call sites, introduce struct qed_chain_init_params to specify chain params, and pass a pointer to filled struct to the actual qed_chain_alloc() instead of a long list of separate arguments. Signed-off-by: Alexander Lobakin <alobakin@marvell.com> Signed-off-by: Igor Russkikh <irusskikh@marvell.com> Signed-off-by: Michal Kalderon <michal.kalderon@marvell.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
c3a321b06a
commit
b6db3f71c9
10 changed files with 242 additions and 233 deletions
|
@ -346,9 +346,14 @@ static void qedr_free_resources(struct qedr_dev *dev)
|
||||||
|
|
||||||
static int qedr_alloc_resources(struct qedr_dev *dev)
|
static int qedr_alloc_resources(struct qedr_dev *dev)
|
||||||
{
|
{
|
||||||
|
struct qed_chain_init_params params = {
|
||||||
|
.mode = QED_CHAIN_MODE_PBL,
|
||||||
|
.intended_use = QED_CHAIN_USE_TO_CONSUME,
|
||||||
|
.cnt_type = QED_CHAIN_CNT_TYPE_U16,
|
||||||
|
.elem_size = sizeof(struct regpair *),
|
||||||
|
};
|
||||||
struct qedr_cnq *cnq;
|
struct qedr_cnq *cnq;
|
||||||
__le16 *cons_pi;
|
__le16 *cons_pi;
|
||||||
u16 n_entries;
|
|
||||||
int i, rc;
|
int i, rc;
|
||||||
|
|
||||||
dev->sgid_tbl = kcalloc(QEDR_MAX_SGID, sizeof(union ib_gid),
|
dev->sgid_tbl = kcalloc(QEDR_MAX_SGID, sizeof(union ib_gid),
|
||||||
|
@ -382,7 +387,9 @@ static int qedr_alloc_resources(struct qedr_dev *dev)
|
||||||
dev->sb_start = dev->ops->rdma_get_start_sb(dev->cdev);
|
dev->sb_start = dev->ops->rdma_get_start_sb(dev->cdev);
|
||||||
|
|
||||||
/* Allocate CNQ PBLs */
|
/* Allocate CNQ PBLs */
|
||||||
n_entries = min_t(u32, QED_RDMA_MAX_CNQ_SIZE, QEDR_ROCE_MAX_CNQ_SIZE);
|
params.num_elems = min_t(u32, QED_RDMA_MAX_CNQ_SIZE,
|
||||||
|
QEDR_ROCE_MAX_CNQ_SIZE);
|
||||||
|
|
||||||
for (i = 0; i < dev->num_cnq; i++) {
|
for (i = 0; i < dev->num_cnq; i++) {
|
||||||
cnq = &dev->cnq_array[i];
|
cnq = &dev->cnq_array[i];
|
||||||
|
|
||||||
|
@ -391,13 +398,8 @@ static int qedr_alloc_resources(struct qedr_dev *dev)
|
||||||
if (rc)
|
if (rc)
|
||||||
goto err3;
|
goto err3;
|
||||||
|
|
||||||
rc = dev->ops->common->chain_alloc(dev->cdev,
|
rc = dev->ops->common->chain_alloc(dev->cdev, &cnq->pbl,
|
||||||
QED_CHAIN_USE_TO_CONSUME,
|
¶ms);
|
||||||
QED_CHAIN_MODE_PBL,
|
|
||||||
QED_CHAIN_CNT_TYPE_U16,
|
|
||||||
n_entries,
|
|
||||||
sizeof(struct regpair *),
|
|
||||||
&cnq->pbl, NULL);
|
|
||||||
if (rc)
|
if (rc)
|
||||||
goto err4;
|
goto err4;
|
||||||
|
|
||||||
|
|
|
@ -891,6 +891,12 @@ int qedr_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr,
|
||||||
udata, struct qedr_ucontext, ibucontext);
|
udata, struct qedr_ucontext, ibucontext);
|
||||||
struct qed_rdma_destroy_cq_out_params destroy_oparams;
|
struct qed_rdma_destroy_cq_out_params destroy_oparams;
|
||||||
struct qed_rdma_destroy_cq_in_params destroy_iparams;
|
struct qed_rdma_destroy_cq_in_params destroy_iparams;
|
||||||
|
struct qed_chain_init_params chain_params = {
|
||||||
|
.mode = QED_CHAIN_MODE_PBL,
|
||||||
|
.intended_use = QED_CHAIN_USE_TO_CONSUME,
|
||||||
|
.cnt_type = QED_CHAIN_CNT_TYPE_U32,
|
||||||
|
.elem_size = sizeof(union rdma_cqe),
|
||||||
|
};
|
||||||
struct qedr_dev *dev = get_qedr_dev(ibdev);
|
struct qedr_dev *dev = get_qedr_dev(ibdev);
|
||||||
struct qed_rdma_create_cq_in_params params;
|
struct qed_rdma_create_cq_in_params params;
|
||||||
struct qedr_create_cq_ureq ureq = {};
|
struct qedr_create_cq_ureq ureq = {};
|
||||||
|
@ -917,6 +923,7 @@ int qedr_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr,
|
||||||
|
|
||||||
chain_entries = qedr_align_cq_entries(entries);
|
chain_entries = qedr_align_cq_entries(entries);
|
||||||
chain_entries = min_t(int, chain_entries, QEDR_MAX_CQES);
|
chain_entries = min_t(int, chain_entries, QEDR_MAX_CQES);
|
||||||
|
chain_params.num_elems = chain_entries;
|
||||||
|
|
||||||
/* calc db offset. user will add DPI base, kernel will add db addr */
|
/* calc db offset. user will add DPI base, kernel will add db addr */
|
||||||
db_offset = DB_ADDR_SHIFT(DQ_PWM_OFFSET_UCM_RDMA_CQ_CONS_32BIT);
|
db_offset = DB_ADDR_SHIFT(DQ_PWM_OFFSET_UCM_RDMA_CQ_CONS_32BIT);
|
||||||
|
@ -951,13 +958,8 @@ int qedr_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr,
|
||||||
} else {
|
} else {
|
||||||
cq->cq_type = QEDR_CQ_TYPE_KERNEL;
|
cq->cq_type = QEDR_CQ_TYPE_KERNEL;
|
||||||
|
|
||||||
rc = dev->ops->common->chain_alloc(dev->cdev,
|
rc = dev->ops->common->chain_alloc(dev->cdev, &cq->pbl,
|
||||||
QED_CHAIN_USE_TO_CONSUME,
|
&chain_params);
|
||||||
QED_CHAIN_MODE_PBL,
|
|
||||||
QED_CHAIN_CNT_TYPE_U32,
|
|
||||||
chain_entries,
|
|
||||||
sizeof(union rdma_cqe),
|
|
||||||
&cq->pbl, NULL);
|
|
||||||
if (rc)
|
if (rc)
|
||||||
goto err0;
|
goto err0;
|
||||||
|
|
||||||
|
@ -1446,6 +1448,12 @@ static int qedr_alloc_srq_kernel_params(struct qedr_srq *srq,
|
||||||
struct ib_srq_init_attr *init_attr)
|
struct ib_srq_init_attr *init_attr)
|
||||||
{
|
{
|
||||||
struct qedr_srq_hwq_info *hw_srq = &srq->hw_srq;
|
struct qedr_srq_hwq_info *hw_srq = &srq->hw_srq;
|
||||||
|
struct qed_chain_init_params params = {
|
||||||
|
.mode = QED_CHAIN_MODE_PBL,
|
||||||
|
.intended_use = QED_CHAIN_USE_TO_CONSUME_PRODUCE,
|
||||||
|
.cnt_type = QED_CHAIN_CNT_TYPE_U32,
|
||||||
|
.elem_size = QEDR_SRQ_WQE_ELEM_SIZE,
|
||||||
|
};
|
||||||
dma_addr_t phy_prod_pair_addr;
|
dma_addr_t phy_prod_pair_addr;
|
||||||
u32 num_elems;
|
u32 num_elems;
|
||||||
void *va;
|
void *va;
|
||||||
|
@ -1464,13 +1472,9 @@ static int qedr_alloc_srq_kernel_params(struct qedr_srq *srq,
|
||||||
hw_srq->virt_prod_pair_addr = va;
|
hw_srq->virt_prod_pair_addr = va;
|
||||||
|
|
||||||
num_elems = init_attr->attr.max_wr * RDMA_MAX_SRQ_WQE_SIZE;
|
num_elems = init_attr->attr.max_wr * RDMA_MAX_SRQ_WQE_SIZE;
|
||||||
rc = dev->ops->common->chain_alloc(dev->cdev,
|
params.num_elems = num_elems;
|
||||||
QED_CHAIN_USE_TO_CONSUME_PRODUCE,
|
|
||||||
QED_CHAIN_MODE_PBL,
|
rc = dev->ops->common->chain_alloc(dev->cdev, &hw_srq->pbl, ¶ms);
|
||||||
QED_CHAIN_CNT_TYPE_U32,
|
|
||||||
num_elems,
|
|
||||||
QEDR_SRQ_WQE_ELEM_SIZE,
|
|
||||||
&hw_srq->pbl, NULL);
|
|
||||||
if (rc)
|
if (rc)
|
||||||
goto err0;
|
goto err0;
|
||||||
|
|
||||||
|
@ -1901,29 +1905,28 @@ qedr_roce_create_kernel_qp(struct qedr_dev *dev,
|
||||||
u32 n_sq_elems, u32 n_rq_elems)
|
u32 n_sq_elems, u32 n_rq_elems)
|
||||||
{
|
{
|
||||||
struct qed_rdma_create_qp_out_params out_params;
|
struct qed_rdma_create_qp_out_params out_params;
|
||||||
|
struct qed_chain_init_params params = {
|
||||||
|
.mode = QED_CHAIN_MODE_PBL,
|
||||||
|
.cnt_type = QED_CHAIN_CNT_TYPE_U32,
|
||||||
|
};
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
rc = dev->ops->common->chain_alloc(dev->cdev,
|
params.intended_use = QED_CHAIN_USE_TO_PRODUCE;
|
||||||
QED_CHAIN_USE_TO_PRODUCE,
|
params.num_elems = n_sq_elems;
|
||||||
QED_CHAIN_MODE_PBL,
|
params.elem_size = QEDR_SQE_ELEMENT_SIZE;
|
||||||
QED_CHAIN_CNT_TYPE_U32,
|
|
||||||
n_sq_elems,
|
|
||||||
QEDR_SQE_ELEMENT_SIZE,
|
|
||||||
&qp->sq.pbl, NULL);
|
|
||||||
|
|
||||||
|
rc = dev->ops->common->chain_alloc(dev->cdev, &qp->sq.pbl, ¶ms);
|
||||||
if (rc)
|
if (rc)
|
||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
in_params->sq_num_pages = qed_chain_get_page_cnt(&qp->sq.pbl);
|
in_params->sq_num_pages = qed_chain_get_page_cnt(&qp->sq.pbl);
|
||||||
in_params->sq_pbl_ptr = qed_chain_get_pbl_phys(&qp->sq.pbl);
|
in_params->sq_pbl_ptr = qed_chain_get_pbl_phys(&qp->sq.pbl);
|
||||||
|
|
||||||
rc = dev->ops->common->chain_alloc(dev->cdev,
|
params.intended_use = QED_CHAIN_USE_TO_CONSUME_PRODUCE;
|
||||||
QED_CHAIN_USE_TO_CONSUME_PRODUCE,
|
params.elem_size = n_rq_elems;
|
||||||
QED_CHAIN_MODE_PBL,
|
params.elem_size = QEDR_RQE_ELEMENT_SIZE;
|
||||||
QED_CHAIN_CNT_TYPE_U32,
|
|
||||||
n_rq_elems,
|
rc = dev->ops->common->chain_alloc(dev->cdev, &qp->rq.pbl, ¶ms);
|
||||||
QEDR_RQE_ELEMENT_SIZE,
|
|
||||||
&qp->rq.pbl, NULL);
|
|
||||||
if (rc)
|
if (rc)
|
||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
|
@ -1949,7 +1952,10 @@ qedr_iwarp_create_kernel_qp(struct qedr_dev *dev,
|
||||||
u32 n_sq_elems, u32 n_rq_elems)
|
u32 n_sq_elems, u32 n_rq_elems)
|
||||||
{
|
{
|
||||||
struct qed_rdma_create_qp_out_params out_params;
|
struct qed_rdma_create_qp_out_params out_params;
|
||||||
struct qed_chain_ext_pbl ext_pbl;
|
struct qed_chain_init_params params = {
|
||||||
|
.mode = QED_CHAIN_MODE_PBL,
|
||||||
|
.cnt_type = QED_CHAIN_CNT_TYPE_U32,
|
||||||
|
};
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
in_params->sq_num_pages = QED_CHAIN_PAGE_CNT(n_sq_elems,
|
in_params->sq_num_pages = QED_CHAIN_PAGE_CNT(n_sq_elems,
|
||||||
|
@ -1966,31 +1972,24 @@ qedr_iwarp_create_kernel_qp(struct qedr_dev *dev,
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
/* Now we allocate the chain */
|
/* Now we allocate the chain */
|
||||||
ext_pbl.p_pbl_virt = out_params.sq_pbl_virt;
|
|
||||||
ext_pbl.p_pbl_phys = out_params.sq_pbl_phys;
|
|
||||||
|
|
||||||
rc = dev->ops->common->chain_alloc(dev->cdev,
|
params.intended_use = QED_CHAIN_USE_TO_PRODUCE;
|
||||||
QED_CHAIN_USE_TO_PRODUCE,
|
params.num_elems = n_sq_elems;
|
||||||
QED_CHAIN_MODE_PBL,
|
params.elem_size = QEDR_SQE_ELEMENT_SIZE;
|
||||||
QED_CHAIN_CNT_TYPE_U32,
|
params.ext_pbl_virt = out_params.sq_pbl_virt;
|
||||||
n_sq_elems,
|
params.ext_pbl_phys = out_params.sq_pbl_phys;
|
||||||
QEDR_SQE_ELEMENT_SIZE,
|
|
||||||
&qp->sq.pbl, &ext_pbl);
|
|
||||||
|
|
||||||
|
rc = dev->ops->common->chain_alloc(dev->cdev, &qp->sq.pbl, ¶ms);
|
||||||
if (rc)
|
if (rc)
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
ext_pbl.p_pbl_virt = out_params.rq_pbl_virt;
|
params.intended_use = QED_CHAIN_USE_TO_CONSUME_PRODUCE;
|
||||||
ext_pbl.p_pbl_phys = out_params.rq_pbl_phys;
|
params.num_elems = n_rq_elems;
|
||||||
|
params.elem_size = QEDR_RQE_ELEMENT_SIZE;
|
||||||
rc = dev->ops->common->chain_alloc(dev->cdev,
|
params.ext_pbl_virt = out_params.rq_pbl_virt;
|
||||||
QED_CHAIN_USE_TO_CONSUME_PRODUCE,
|
params.ext_pbl_phys = out_params.rq_pbl_phys;
|
||||||
QED_CHAIN_MODE_PBL,
|
|
||||||
QED_CHAIN_CNT_TYPE_U32,
|
|
||||||
n_rq_elems,
|
|
||||||
QEDR_RQE_ELEMENT_SIZE,
|
|
||||||
&qp->rq.pbl, &ext_pbl);
|
|
||||||
|
|
||||||
|
rc = dev->ops->common->chain_alloc(dev->cdev, &qp->rq.pbl, ¶ms);
|
||||||
if (rc)
|
if (rc)
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
|
|
|
@ -7,23 +7,22 @@
|
||||||
|
|
||||||
#include "qed_dev_api.h"
|
#include "qed_dev_api.h"
|
||||||
|
|
||||||
static void qed_chain_init_params(struct qed_chain *chain,
|
static void qed_chain_init(struct qed_chain *chain,
|
||||||
u32 page_cnt, u8 elem_size,
|
const struct qed_chain_init_params *params,
|
||||||
enum qed_chain_use_mode intended_use,
|
u32 page_cnt)
|
||||||
enum qed_chain_mode mode,
|
|
||||||
enum qed_chain_cnt_type cnt_type,
|
|
||||||
const struct qed_chain_ext_pbl *ext_pbl)
|
|
||||||
{
|
{
|
||||||
memset(chain, 0, sizeof(*chain));
|
memset(chain, 0, sizeof(*chain));
|
||||||
|
|
||||||
chain->elem_size = elem_size;
|
chain->elem_size = params->elem_size;
|
||||||
chain->intended_use = intended_use;
|
chain->intended_use = params->intended_use;
|
||||||
chain->mode = mode;
|
chain->mode = params->mode;
|
||||||
chain->cnt_type = cnt_type;
|
chain->cnt_type = params->cnt_type;
|
||||||
|
|
||||||
chain->elem_per_page = ELEMS_PER_PAGE(elem_size);
|
chain->elem_per_page = ELEMS_PER_PAGE(params->elem_size);
|
||||||
chain->usable_per_page = USABLE_ELEMS_PER_PAGE(elem_size, mode);
|
chain->usable_per_page = USABLE_ELEMS_PER_PAGE(params->elem_size,
|
||||||
chain->elem_unusable = UNUSABLE_ELEMS_PER_PAGE(elem_size, mode);
|
params->mode);
|
||||||
|
chain->elem_unusable = UNUSABLE_ELEMS_PER_PAGE(params->elem_size,
|
||||||
|
params->mode);
|
||||||
|
|
||||||
chain->elem_per_page_mask = chain->elem_per_page - 1;
|
chain->elem_per_page_mask = chain->elem_per_page - 1;
|
||||||
chain->next_page_mask = chain->usable_per_page &
|
chain->next_page_mask = chain->usable_per_page &
|
||||||
|
@ -33,9 +32,9 @@ static void qed_chain_init_params(struct qed_chain *chain,
|
||||||
chain->capacity = chain->usable_per_page * page_cnt;
|
chain->capacity = chain->usable_per_page * page_cnt;
|
||||||
chain->size = chain->elem_per_page * page_cnt;
|
chain->size = chain->elem_per_page * page_cnt;
|
||||||
|
|
||||||
if (ext_pbl && ext_pbl->p_pbl_virt) {
|
if (params->ext_pbl_virt) {
|
||||||
chain->pbl_sp.table_virt = ext_pbl->p_pbl_virt;
|
chain->pbl_sp.table_virt = params->ext_pbl_virt;
|
||||||
chain->pbl_sp.table_phys = ext_pbl->p_pbl_phys;
|
chain->pbl_sp.table_phys = params->ext_pbl_phys;
|
||||||
|
|
||||||
chain->b_external_pbl = true;
|
chain->b_external_pbl = true;
|
||||||
}
|
}
|
||||||
|
@ -154,10 +153,16 @@ void qed_chain_free(struct qed_dev *cdev, struct qed_chain *chain)
|
||||||
|
|
||||||
static int
|
static int
|
||||||
qed_chain_alloc_sanity_check(struct qed_dev *cdev,
|
qed_chain_alloc_sanity_check(struct qed_dev *cdev,
|
||||||
enum qed_chain_cnt_type cnt_type,
|
const struct qed_chain_init_params *params,
|
||||||
size_t elem_size, u32 page_cnt)
|
u32 page_cnt)
|
||||||
{
|
{
|
||||||
u64 chain_size = ELEMS_PER_PAGE(elem_size) * page_cnt;
|
u64 chain_size;
|
||||||
|
|
||||||
|
chain_size = ELEMS_PER_PAGE(params->elem_size);
|
||||||
|
chain_size *= page_cnt;
|
||||||
|
|
||||||
|
if (!chain_size)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
/* The actual chain size can be larger than the maximal possible value
|
/* The actual chain size can be larger than the maximal possible value
|
||||||
* after rounding up the requested elements number to pages, and after
|
* after rounding up the requested elements number to pages, and after
|
||||||
|
@ -165,7 +170,7 @@ qed_chain_alloc_sanity_check(struct qed_dev *cdev,
|
||||||
* The size of a "u16" chain can be (U16_MAX + 1) since the chain
|
* The size of a "u16" chain can be (U16_MAX + 1) since the chain
|
||||||
* size/capacity fields are of u32 type.
|
* size/capacity fields are of u32 type.
|
||||||
*/
|
*/
|
||||||
switch (cnt_type) {
|
switch (params->cnt_type) {
|
||||||
case QED_CHAIN_CNT_TYPE_U16:
|
case QED_CHAIN_CNT_TYPE_U16:
|
||||||
if (chain_size > U16_MAX + 1)
|
if (chain_size > U16_MAX + 1)
|
||||||
break;
|
break;
|
||||||
|
@ -298,37 +303,42 @@ static int qed_chain_alloc_pbl(struct qed_dev *cdev, struct qed_chain *chain)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int qed_chain_alloc(struct qed_dev *cdev,
|
/**
|
||||||
enum qed_chain_use_mode intended_use,
|
* qed_chain_alloc() - Allocate and initialize a chain.
|
||||||
enum qed_chain_mode mode,
|
*
|
||||||
enum qed_chain_cnt_type cnt_type,
|
* @cdev: Main device structure.
|
||||||
u32 num_elems,
|
* @chain: Chain to be processed.
|
||||||
size_t elem_size,
|
* @params: Chain initialization parameters.
|
||||||
struct qed_chain *chain,
|
*
|
||||||
struct qed_chain_ext_pbl *ext_pbl)
|
* Return: 0 on success, negative errno otherwise.
|
||||||
|
*/
|
||||||
|
int qed_chain_alloc(struct qed_dev *cdev, struct qed_chain *chain,
|
||||||
|
struct qed_chain_init_params *params)
|
||||||
{
|
{
|
||||||
u32 page_cnt;
|
u32 page_cnt;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
if (mode == QED_CHAIN_MODE_SINGLE)
|
if (params->mode == QED_CHAIN_MODE_SINGLE)
|
||||||
page_cnt = 1;
|
page_cnt = 1;
|
||||||
else
|
else
|
||||||
page_cnt = QED_CHAIN_PAGE_CNT(num_elems, elem_size, mode);
|
page_cnt = QED_CHAIN_PAGE_CNT(params->num_elems,
|
||||||
|
params->elem_size,
|
||||||
|
params->mode);
|
||||||
|
|
||||||
rc = qed_chain_alloc_sanity_check(cdev, cnt_type, elem_size, page_cnt);
|
rc = qed_chain_alloc_sanity_check(cdev, params, page_cnt);
|
||||||
if (rc) {
|
if (rc) {
|
||||||
DP_NOTICE(cdev,
|
DP_NOTICE(cdev,
|
||||||
"Cannot allocate a chain with the given arguments:\n");
|
"Cannot allocate a chain with the given arguments:\n");
|
||||||
DP_NOTICE(cdev,
|
DP_NOTICE(cdev,
|
||||||
"[use_mode %d, mode %d, cnt_type %d, num_elems %d, elem_size %zu]\n",
|
"[use_mode %d, mode %d, cnt_type %d, num_elems %d, elem_size %zu]\n",
|
||||||
intended_use, mode, cnt_type, num_elems, elem_size);
|
params->intended_use, params->mode, params->cnt_type,
|
||||||
|
params->num_elems, params->elem_size);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
qed_chain_init_params(chain, page_cnt, elem_size, intended_use, mode,
|
qed_chain_init(chain, params, page_cnt);
|
||||||
cnt_type, ext_pbl);
|
|
||||||
|
|
||||||
switch (mode) {
|
switch (params->mode) {
|
||||||
case QED_CHAIN_MODE_NEXT_PTR:
|
case QED_CHAIN_MODE_NEXT_PTR:
|
||||||
rc = qed_chain_alloc_next_ptr(cdev, chain);
|
rc = qed_chain_alloc_next_ptr(cdev, chain);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -254,35 +254,9 @@ int qed_dmae_host2host(struct qed_hwfn *p_hwfn,
|
||||||
dma_addr_t dest_addr,
|
dma_addr_t dest_addr,
|
||||||
u32 size_in_dwords, struct qed_dmae_params *p_params);
|
u32 size_in_dwords, struct qed_dmae_params *p_params);
|
||||||
|
|
||||||
/**
|
int qed_chain_alloc(struct qed_dev *cdev, struct qed_chain *chain,
|
||||||
* @brief qed_chain_alloc - Allocate and initialize a chain
|
struct qed_chain_init_params *params);
|
||||||
*
|
void qed_chain_free(struct qed_dev *cdev, struct qed_chain *chain);
|
||||||
* @param p_hwfn
|
|
||||||
* @param intended_use
|
|
||||||
* @param mode
|
|
||||||
* @param num_elems
|
|
||||||
* @param elem_size
|
|
||||||
* @param p_chain
|
|
||||||
* @param ext_pbl - a possible external PBL
|
|
||||||
*
|
|
||||||
* @return int
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
qed_chain_alloc(struct qed_dev *cdev,
|
|
||||||
enum qed_chain_use_mode intended_use,
|
|
||||||
enum qed_chain_mode mode,
|
|
||||||
enum qed_chain_cnt_type cnt_type,
|
|
||||||
u32 num_elems,
|
|
||||||
size_t elem_size,
|
|
||||||
struct qed_chain *p_chain, struct qed_chain_ext_pbl *ext_pbl);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief qed_chain_free - Free chain DMA memory
|
|
||||||
*
|
|
||||||
* @param p_hwfn
|
|
||||||
* @param p_chain
|
|
||||||
*/
|
|
||||||
void qed_chain_free(struct qed_dev *cdev, struct qed_chain *p_chain);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @@brief qed_fw_l2_queue - Get absolute L2 queue ID
|
* @@brief qed_fw_l2_queue - Get absolute L2 queue ID
|
||||||
|
|
|
@ -684,9 +684,13 @@ static int qed_iscsi_setup_connection(struct qed_iscsi_conn *p_conn)
|
||||||
static int qed_iscsi_allocate_connection(struct qed_hwfn *p_hwfn,
|
static int qed_iscsi_allocate_connection(struct qed_hwfn *p_hwfn,
|
||||||
struct qed_iscsi_conn **p_out_conn)
|
struct qed_iscsi_conn **p_out_conn)
|
||||||
{
|
{
|
||||||
u16 uhq_num_elements = 0, xhq_num_elements = 0, r2tq_num_elements = 0;
|
|
||||||
struct scsi_terminate_extra_params *p_q_cnts = NULL;
|
struct scsi_terminate_extra_params *p_q_cnts = NULL;
|
||||||
struct qed_iscsi_pf_params *p_params = NULL;
|
struct qed_iscsi_pf_params *p_params = NULL;
|
||||||
|
struct qed_chain_init_params params = {
|
||||||
|
.mode = QED_CHAIN_MODE_PBL,
|
||||||
|
.intended_use = QED_CHAIN_USE_TO_CONSUME_PRODUCE,
|
||||||
|
.cnt_type = QED_CHAIN_CNT_TYPE_U16,
|
||||||
|
};
|
||||||
struct tcp_upload_params *p_tcp = NULL;
|
struct tcp_upload_params *p_tcp = NULL;
|
||||||
struct qed_iscsi_conn *p_conn = NULL;
|
struct qed_iscsi_conn *p_conn = NULL;
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
@ -727,34 +731,25 @@ static int qed_iscsi_allocate_connection(struct qed_hwfn *p_hwfn,
|
||||||
goto nomem_upload_param;
|
goto nomem_upload_param;
|
||||||
p_conn->tcp_upload_params_virt_addr = p_tcp;
|
p_conn->tcp_upload_params_virt_addr = p_tcp;
|
||||||
|
|
||||||
r2tq_num_elements = p_params->num_r2tq_pages_in_ring *
|
params.num_elems = p_params->num_r2tq_pages_in_ring *
|
||||||
QED_CHAIN_PAGE_SIZE / 0x80;
|
QED_CHAIN_PAGE_SIZE / sizeof(struct iscsi_wqe);
|
||||||
rc = qed_chain_alloc(p_hwfn->cdev,
|
params.elem_size = sizeof(struct iscsi_wqe);
|
||||||
QED_CHAIN_USE_TO_CONSUME_PRODUCE,
|
|
||||||
QED_CHAIN_MODE_PBL,
|
rc = qed_chain_alloc(p_hwfn->cdev, &p_conn->r2tq, ¶ms);
|
||||||
QED_CHAIN_CNT_TYPE_U16,
|
|
||||||
r2tq_num_elements, 0x80, &p_conn->r2tq, NULL);
|
|
||||||
if (rc)
|
if (rc)
|
||||||
goto nomem_r2tq;
|
goto nomem_r2tq;
|
||||||
|
|
||||||
uhq_num_elements = p_params->num_uhq_pages_in_ring *
|
params.num_elems = p_params->num_uhq_pages_in_ring *
|
||||||
QED_CHAIN_PAGE_SIZE / sizeof(struct iscsi_uhqe);
|
QED_CHAIN_PAGE_SIZE / sizeof(struct iscsi_uhqe);
|
||||||
rc = qed_chain_alloc(p_hwfn->cdev,
|
params.elem_size = sizeof(struct iscsi_uhqe);
|
||||||
QED_CHAIN_USE_TO_CONSUME_PRODUCE,
|
|
||||||
QED_CHAIN_MODE_PBL,
|
rc = qed_chain_alloc(p_hwfn->cdev, &p_conn->uhq, ¶ms);
|
||||||
QED_CHAIN_CNT_TYPE_U16,
|
|
||||||
uhq_num_elements,
|
|
||||||
sizeof(struct iscsi_uhqe), &p_conn->uhq, NULL);
|
|
||||||
if (rc)
|
if (rc)
|
||||||
goto nomem_uhq;
|
goto nomem_uhq;
|
||||||
|
|
||||||
xhq_num_elements = uhq_num_elements;
|
params.elem_size = sizeof(struct iscsi_xhqe);
|
||||||
rc = qed_chain_alloc(p_hwfn->cdev,
|
|
||||||
QED_CHAIN_USE_TO_CONSUME_PRODUCE,
|
rc = qed_chain_alloc(p_hwfn->cdev, &p_conn->xhq, ¶ms);
|
||||||
QED_CHAIN_MODE_PBL,
|
|
||||||
QED_CHAIN_CNT_TYPE_U16,
|
|
||||||
xhq_num_elements,
|
|
||||||
sizeof(struct iscsi_xhqe), &p_conn->xhq, NULL);
|
|
||||||
if (rc)
|
if (rc)
|
||||||
goto nomem;
|
goto nomem;
|
||||||
|
|
||||||
|
|
|
@ -1125,6 +1125,12 @@ static int
|
||||||
qed_ll2_acquire_connection_rx(struct qed_hwfn *p_hwfn,
|
qed_ll2_acquire_connection_rx(struct qed_hwfn *p_hwfn,
|
||||||
struct qed_ll2_info *p_ll2_info)
|
struct qed_ll2_info *p_ll2_info)
|
||||||
{
|
{
|
||||||
|
struct qed_chain_init_params params = {
|
||||||
|
.intended_use = QED_CHAIN_USE_TO_CONSUME_PRODUCE,
|
||||||
|
.cnt_type = QED_CHAIN_CNT_TYPE_U16,
|
||||||
|
.num_elems = p_ll2_info->input.rx_num_desc,
|
||||||
|
};
|
||||||
|
struct qed_dev *cdev = p_hwfn->cdev;
|
||||||
struct qed_ll2_rx_packet *p_descq;
|
struct qed_ll2_rx_packet *p_descq;
|
||||||
u32 capacity;
|
u32 capacity;
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
@ -1132,13 +1138,10 @@ qed_ll2_acquire_connection_rx(struct qed_hwfn *p_hwfn,
|
||||||
if (!p_ll2_info->input.rx_num_desc)
|
if (!p_ll2_info->input.rx_num_desc)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
rc = qed_chain_alloc(p_hwfn->cdev,
|
params.mode = QED_CHAIN_MODE_NEXT_PTR;
|
||||||
QED_CHAIN_USE_TO_CONSUME_PRODUCE,
|
params.elem_size = sizeof(struct core_rx_bd);
|
||||||
QED_CHAIN_MODE_NEXT_PTR,
|
|
||||||
QED_CHAIN_CNT_TYPE_U16,
|
rc = qed_chain_alloc(cdev, &p_ll2_info->rx_queue.rxq_chain, ¶ms);
|
||||||
p_ll2_info->input.rx_num_desc,
|
|
||||||
sizeof(struct core_rx_bd),
|
|
||||||
&p_ll2_info->rx_queue.rxq_chain, NULL);
|
|
||||||
if (rc) {
|
if (rc) {
|
||||||
DP_NOTICE(p_hwfn, "Failed to allocate ll2 rxq chain\n");
|
DP_NOTICE(p_hwfn, "Failed to allocate ll2 rxq chain\n");
|
||||||
goto out;
|
goto out;
|
||||||
|
@ -1154,13 +1157,10 @@ qed_ll2_acquire_connection_rx(struct qed_hwfn *p_hwfn,
|
||||||
}
|
}
|
||||||
p_ll2_info->rx_queue.descq_array = p_descq;
|
p_ll2_info->rx_queue.descq_array = p_descq;
|
||||||
|
|
||||||
rc = qed_chain_alloc(p_hwfn->cdev,
|
params.mode = QED_CHAIN_MODE_PBL;
|
||||||
QED_CHAIN_USE_TO_CONSUME_PRODUCE,
|
params.elem_size = sizeof(struct core_rx_fast_path_cqe);
|
||||||
QED_CHAIN_MODE_PBL,
|
|
||||||
QED_CHAIN_CNT_TYPE_U16,
|
rc = qed_chain_alloc(cdev, &p_ll2_info->rx_queue.rcq_chain, ¶ms);
|
||||||
p_ll2_info->input.rx_num_desc,
|
|
||||||
sizeof(struct core_rx_fast_path_cqe),
|
|
||||||
&p_ll2_info->rx_queue.rcq_chain, NULL);
|
|
||||||
if (rc) {
|
if (rc) {
|
||||||
DP_NOTICE(p_hwfn, "Failed to allocate ll2 rcq chain\n");
|
DP_NOTICE(p_hwfn, "Failed to allocate ll2 rcq chain\n");
|
||||||
goto out;
|
goto out;
|
||||||
|
@ -1177,6 +1177,13 @@ qed_ll2_acquire_connection_rx(struct qed_hwfn *p_hwfn,
|
||||||
static int qed_ll2_acquire_connection_tx(struct qed_hwfn *p_hwfn,
|
static int qed_ll2_acquire_connection_tx(struct qed_hwfn *p_hwfn,
|
||||||
struct qed_ll2_info *p_ll2_info)
|
struct qed_ll2_info *p_ll2_info)
|
||||||
{
|
{
|
||||||
|
struct qed_chain_init_params params = {
|
||||||
|
.mode = QED_CHAIN_MODE_PBL,
|
||||||
|
.intended_use = QED_CHAIN_USE_TO_CONSUME_PRODUCE,
|
||||||
|
.cnt_type = QED_CHAIN_CNT_TYPE_U16,
|
||||||
|
.num_elems = p_ll2_info->input.tx_num_desc,
|
||||||
|
.elem_size = sizeof(struct core_tx_bd),
|
||||||
|
};
|
||||||
struct qed_ll2_tx_packet *p_descq;
|
struct qed_ll2_tx_packet *p_descq;
|
||||||
u32 desc_size;
|
u32 desc_size;
|
||||||
u32 capacity;
|
u32 capacity;
|
||||||
|
@ -1185,13 +1192,8 @@ static int qed_ll2_acquire_connection_tx(struct qed_hwfn *p_hwfn,
|
||||||
if (!p_ll2_info->input.tx_num_desc)
|
if (!p_ll2_info->input.tx_num_desc)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
rc = qed_chain_alloc(p_hwfn->cdev,
|
rc = qed_chain_alloc(p_hwfn->cdev, &p_ll2_info->tx_queue.txq_chain,
|
||||||
QED_CHAIN_USE_TO_CONSUME_PRODUCE,
|
¶ms);
|
||||||
QED_CHAIN_MODE_PBL,
|
|
||||||
QED_CHAIN_CNT_TYPE_U16,
|
|
||||||
p_ll2_info->input.tx_num_desc,
|
|
||||||
sizeof(struct core_tx_bd),
|
|
||||||
&p_ll2_info->tx_queue.txq_chain, NULL);
|
|
||||||
if (rc)
|
if (rc)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
|
|
|
@ -382,22 +382,26 @@ int qed_eq_completion(struct qed_hwfn *p_hwfn, void *cookie)
|
||||||
|
|
||||||
int qed_eq_alloc(struct qed_hwfn *p_hwfn, u16 num_elem)
|
int qed_eq_alloc(struct qed_hwfn *p_hwfn, u16 num_elem)
|
||||||
{
|
{
|
||||||
|
struct qed_chain_init_params params = {
|
||||||
|
.mode = QED_CHAIN_MODE_PBL,
|
||||||
|
.intended_use = QED_CHAIN_USE_TO_PRODUCE,
|
||||||
|
.cnt_type = QED_CHAIN_CNT_TYPE_U16,
|
||||||
|
.num_elems = num_elem,
|
||||||
|
.elem_size = sizeof(union event_ring_element),
|
||||||
|
};
|
||||||
struct qed_eq *p_eq;
|
struct qed_eq *p_eq;
|
||||||
|
int ret;
|
||||||
|
|
||||||
/* Allocate EQ struct */
|
/* Allocate EQ struct */
|
||||||
p_eq = kzalloc(sizeof(*p_eq), GFP_KERNEL);
|
p_eq = kzalloc(sizeof(*p_eq), GFP_KERNEL);
|
||||||
if (!p_eq)
|
if (!p_eq)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
/* Allocate and initialize EQ chain*/
|
ret = qed_chain_alloc(p_hwfn->cdev, &p_eq->chain, ¶ms);
|
||||||
if (qed_chain_alloc(p_hwfn->cdev,
|
if (ret) {
|
||||||
QED_CHAIN_USE_TO_PRODUCE,
|
DP_NOTICE(p_hwfn, "Failed to allocate EQ chain\n");
|
||||||
QED_CHAIN_MODE_PBL,
|
|
||||||
QED_CHAIN_CNT_TYPE_U16,
|
|
||||||
num_elem,
|
|
||||||
sizeof(union event_ring_element),
|
|
||||||
&p_eq->chain, NULL))
|
|
||||||
goto eq_allocate_fail;
|
goto eq_allocate_fail;
|
||||||
|
}
|
||||||
|
|
||||||
/* register EQ completion on the SP SB */
|
/* register EQ completion on the SP SB */
|
||||||
qed_int_register_cb(p_hwfn, qed_eq_completion,
|
qed_int_register_cb(p_hwfn, qed_eq_completion,
|
||||||
|
@ -408,7 +412,8 @@ int qed_eq_alloc(struct qed_hwfn *p_hwfn, u16 num_elem)
|
||||||
|
|
||||||
eq_allocate_fail:
|
eq_allocate_fail:
|
||||||
kfree(p_eq);
|
kfree(p_eq);
|
||||||
return -ENOMEM;
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void qed_eq_setup(struct qed_hwfn *p_hwfn)
|
void qed_eq_setup(struct qed_hwfn *p_hwfn)
|
||||||
|
@ -529,33 +534,40 @@ void qed_spq_setup(struct qed_hwfn *p_hwfn)
|
||||||
|
|
||||||
int qed_spq_alloc(struct qed_hwfn *p_hwfn)
|
int qed_spq_alloc(struct qed_hwfn *p_hwfn)
|
||||||
{
|
{
|
||||||
|
struct qed_chain_init_params params = {
|
||||||
|
.mode = QED_CHAIN_MODE_SINGLE,
|
||||||
|
.intended_use = QED_CHAIN_USE_TO_PRODUCE,
|
||||||
|
.cnt_type = QED_CHAIN_CNT_TYPE_U16,
|
||||||
|
.elem_size = sizeof(struct slow_path_element),
|
||||||
|
};
|
||||||
|
struct qed_dev *cdev = p_hwfn->cdev;
|
||||||
struct qed_spq_entry *p_virt = NULL;
|
struct qed_spq_entry *p_virt = NULL;
|
||||||
struct qed_spq *p_spq = NULL;
|
struct qed_spq *p_spq = NULL;
|
||||||
dma_addr_t p_phys = 0;
|
dma_addr_t p_phys = 0;
|
||||||
u32 capacity;
|
u32 capacity;
|
||||||
|
int ret;
|
||||||
|
|
||||||
/* SPQ struct */
|
/* SPQ struct */
|
||||||
p_spq = kzalloc(sizeof(struct qed_spq), GFP_KERNEL);
|
p_spq = kzalloc(sizeof(struct qed_spq), GFP_KERNEL);
|
||||||
if (!p_spq)
|
if (!p_spq)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
/* SPQ ring */
|
/* SPQ ring */
|
||||||
if (qed_chain_alloc(p_hwfn->cdev,
|
ret = qed_chain_alloc(cdev, &p_spq->chain, ¶ms);
|
||||||
QED_CHAIN_USE_TO_PRODUCE,
|
if (ret) {
|
||||||
QED_CHAIN_MODE_SINGLE,
|
DP_NOTICE(p_hwfn, "Failed to allocate SPQ chain\n");
|
||||||
QED_CHAIN_CNT_TYPE_U16,
|
goto spq_chain_alloc_fail;
|
||||||
0, /* N/A when the mode is SINGLE */
|
}
|
||||||
sizeof(struct slow_path_element),
|
|
||||||
&p_spq->chain, NULL))
|
|
||||||
goto spq_allocate_fail;
|
|
||||||
|
|
||||||
/* allocate and fill the SPQ elements (incl. ramrod data list) */
|
/* allocate and fill the SPQ elements (incl. ramrod data list) */
|
||||||
capacity = qed_chain_get_capacity(&p_spq->chain);
|
capacity = qed_chain_get_capacity(&p_spq->chain);
|
||||||
p_virt = dma_alloc_coherent(&p_hwfn->cdev->pdev->dev,
|
ret = -ENOMEM;
|
||||||
|
|
||||||
|
p_virt = dma_alloc_coherent(&cdev->pdev->dev,
|
||||||
capacity * sizeof(struct qed_spq_entry),
|
capacity * sizeof(struct qed_spq_entry),
|
||||||
&p_phys, GFP_KERNEL);
|
&p_phys, GFP_KERNEL);
|
||||||
if (!p_virt)
|
if (!p_virt)
|
||||||
goto spq_allocate_fail;
|
goto spq_alloc_fail;
|
||||||
|
|
||||||
p_spq->p_virt = p_virt;
|
p_spq->p_virt = p_virt;
|
||||||
p_spq->p_phys = p_phys;
|
p_spq->p_phys = p_phys;
|
||||||
|
@ -563,10 +575,12 @@ int qed_spq_alloc(struct qed_hwfn *p_hwfn)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
spq_allocate_fail:
|
spq_alloc_fail:
|
||||||
qed_chain_free(p_hwfn->cdev, &p_spq->chain);
|
qed_chain_free(cdev, &p_spq->chain);
|
||||||
|
spq_chain_alloc_fail:
|
||||||
kfree(p_spq);
|
kfree(p_spq);
|
||||||
return -ENOMEM;
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void qed_spq_free(struct qed_hwfn *p_hwfn)
|
void qed_spq_free(struct qed_hwfn *p_hwfn)
|
||||||
|
@ -967,30 +981,40 @@ int qed_spq_completion(struct qed_hwfn *p_hwfn,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define QED_SPQ_CONSQ_ELEM_SIZE 0x80
|
||||||
|
|
||||||
int qed_consq_alloc(struct qed_hwfn *p_hwfn)
|
int qed_consq_alloc(struct qed_hwfn *p_hwfn)
|
||||||
{
|
{
|
||||||
|
struct qed_chain_init_params params = {
|
||||||
|
.mode = QED_CHAIN_MODE_PBL,
|
||||||
|
.intended_use = QED_CHAIN_USE_TO_PRODUCE,
|
||||||
|
.cnt_type = QED_CHAIN_CNT_TYPE_U16,
|
||||||
|
.num_elems = QED_CHAIN_PAGE_SIZE / QED_SPQ_CONSQ_ELEM_SIZE,
|
||||||
|
.elem_size = QED_SPQ_CONSQ_ELEM_SIZE,
|
||||||
|
};
|
||||||
struct qed_consq *p_consq;
|
struct qed_consq *p_consq;
|
||||||
|
int ret;
|
||||||
|
|
||||||
/* Allocate ConsQ struct */
|
/* Allocate ConsQ struct */
|
||||||
p_consq = kzalloc(sizeof(*p_consq), GFP_KERNEL);
|
p_consq = kzalloc(sizeof(*p_consq), GFP_KERNEL);
|
||||||
if (!p_consq)
|
if (!p_consq)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
/* Allocate and initialize EQ chain*/
|
/* Allocate and initialize ConsQ chain */
|
||||||
if (qed_chain_alloc(p_hwfn->cdev,
|
ret = qed_chain_alloc(p_hwfn->cdev, &p_consq->chain, ¶ms);
|
||||||
QED_CHAIN_USE_TO_PRODUCE,
|
if (ret) {
|
||||||
QED_CHAIN_MODE_PBL,
|
DP_NOTICE(p_hwfn, "Failed to allocate ConsQ chain");
|
||||||
QED_CHAIN_CNT_TYPE_U16,
|
goto consq_alloc_fail;
|
||||||
QED_CHAIN_PAGE_SIZE / 0x80,
|
}
|
||||||
0x80, &p_consq->chain, NULL))
|
|
||||||
goto consq_allocate_fail;
|
|
||||||
|
|
||||||
p_hwfn->p_consq = p_consq;
|
p_hwfn->p_consq = p_consq;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
consq_allocate_fail:
|
consq_alloc_fail:
|
||||||
kfree(p_consq);
|
kfree(p_consq);
|
||||||
return -ENOMEM;
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void qed_consq_setup(struct qed_hwfn *p_hwfn)
|
void qed_consq_setup(struct qed_hwfn *p_hwfn)
|
||||||
|
|
|
@ -1442,6 +1442,11 @@ static void qede_set_tpa_param(struct qede_rx_queue *rxq)
|
||||||
/* This function allocates all memory needed per Rx queue */
|
/* This function allocates all memory needed per Rx queue */
|
||||||
static int qede_alloc_mem_rxq(struct qede_dev *edev, struct qede_rx_queue *rxq)
|
static int qede_alloc_mem_rxq(struct qede_dev *edev, struct qede_rx_queue *rxq)
|
||||||
{
|
{
|
||||||
|
struct qed_chain_init_params params = {
|
||||||
|
.cnt_type = QED_CHAIN_CNT_TYPE_U16,
|
||||||
|
.num_elems = RX_RING_SIZE,
|
||||||
|
};
|
||||||
|
struct qed_dev *cdev = edev->cdev;
|
||||||
int i, rc, size;
|
int i, rc, size;
|
||||||
|
|
||||||
rxq->num_rx_buffers = edev->q_num_rx_buffers;
|
rxq->num_rx_buffers = edev->q_num_rx_buffers;
|
||||||
|
@ -1477,24 +1482,20 @@ static int qede_alloc_mem_rxq(struct qede_dev *edev, struct qede_rx_queue *rxq)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Allocate FW Rx ring */
|
/* Allocate FW Rx ring */
|
||||||
rc = edev->ops->common->chain_alloc(edev->cdev,
|
params.mode = QED_CHAIN_MODE_NEXT_PTR;
|
||||||
QED_CHAIN_USE_TO_CONSUME_PRODUCE,
|
params.intended_use = QED_CHAIN_USE_TO_CONSUME_PRODUCE;
|
||||||
QED_CHAIN_MODE_NEXT_PTR,
|
params.elem_size = sizeof(struct eth_rx_bd);
|
||||||
QED_CHAIN_CNT_TYPE_U16,
|
|
||||||
RX_RING_SIZE,
|
rc = edev->ops->common->chain_alloc(cdev, &rxq->rx_bd_ring, ¶ms);
|
||||||
sizeof(struct eth_rx_bd),
|
|
||||||
&rxq->rx_bd_ring, NULL);
|
|
||||||
if (rc)
|
if (rc)
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
/* Allocate FW completion ring */
|
/* Allocate FW completion ring */
|
||||||
rc = edev->ops->common->chain_alloc(edev->cdev,
|
params.mode = QED_CHAIN_MODE_PBL;
|
||||||
QED_CHAIN_USE_TO_CONSUME,
|
params.intended_use = QED_CHAIN_USE_TO_CONSUME;
|
||||||
QED_CHAIN_MODE_PBL,
|
params.elem_size = sizeof(union eth_rx_cqe);
|
||||||
QED_CHAIN_CNT_TYPE_U16,
|
|
||||||
RX_RING_SIZE,
|
rc = edev->ops->common->chain_alloc(cdev, &rxq->rx_comp_ring, ¶ms);
|
||||||
sizeof(union eth_rx_cqe),
|
|
||||||
&rxq->rx_comp_ring, NULL);
|
|
||||||
if (rc)
|
if (rc)
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
|
@ -1531,7 +1532,13 @@ static void qede_free_mem_txq(struct qede_dev *edev, struct qede_tx_queue *txq)
|
||||||
/* This function allocates all memory needed per Tx queue */
|
/* This function allocates all memory needed per Tx queue */
|
||||||
static int qede_alloc_mem_txq(struct qede_dev *edev, struct qede_tx_queue *txq)
|
static int qede_alloc_mem_txq(struct qede_dev *edev, struct qede_tx_queue *txq)
|
||||||
{
|
{
|
||||||
union eth_tx_bd_types *p_virt;
|
struct qed_chain_init_params params = {
|
||||||
|
.mode = QED_CHAIN_MODE_PBL,
|
||||||
|
.intended_use = QED_CHAIN_USE_TO_CONSUME_PRODUCE,
|
||||||
|
.cnt_type = QED_CHAIN_CNT_TYPE_U16,
|
||||||
|
.num_elems = edev->q_num_tx_buffers,
|
||||||
|
.elem_size = sizeof(union eth_tx_bd_types),
|
||||||
|
};
|
||||||
int size, rc;
|
int size, rc;
|
||||||
|
|
||||||
txq->num_tx_buffers = edev->q_num_tx_buffers;
|
txq->num_tx_buffers = edev->q_num_tx_buffers;
|
||||||
|
@ -1549,13 +1556,7 @@ static int qede_alloc_mem_txq(struct qede_dev *edev, struct qede_tx_queue *txq)
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = edev->ops->common->chain_alloc(edev->cdev,
|
rc = edev->ops->common->chain_alloc(edev->cdev, &txq->tx_pbl, ¶ms);
|
||||||
QED_CHAIN_USE_TO_CONSUME_PRODUCE,
|
|
||||||
QED_CHAIN_MODE_PBL,
|
|
||||||
QED_CHAIN_CNT_TYPE_U16,
|
|
||||||
txq->num_tx_buffers,
|
|
||||||
sizeof(*p_virt),
|
|
||||||
&txq->tx_pbl, NULL);
|
|
||||||
if (rc)
|
if (rc)
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
|
|
|
@ -54,11 +54,6 @@ struct qed_chain_pbl_u32 {
|
||||||
u32 cons_page_idx;
|
u32 cons_page_idx;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct qed_chain_ext_pbl {
|
|
||||||
dma_addr_t p_pbl_phys;
|
|
||||||
void *p_pbl_virt;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct qed_chain_u16 {
|
struct qed_chain_u16 {
|
||||||
/* Cyclic index of next element to produce/consme */
|
/* Cyclic index of next element to produce/consme */
|
||||||
u16 prod_idx;
|
u16 prod_idx;
|
||||||
|
@ -119,7 +114,7 @@ struct qed_chain {
|
||||||
u16 usable_per_page;
|
u16 usable_per_page;
|
||||||
u8 elem_unusable;
|
u8 elem_unusable;
|
||||||
|
|
||||||
u8 cnt_type;
|
enum qed_chain_cnt_type cnt_type;
|
||||||
|
|
||||||
/* Slowpath of the chain - required for initialization and destruction,
|
/* Slowpath of the chain - required for initialization and destruction,
|
||||||
* but isn't involved in regular functionality.
|
* but isn't involved in regular functionality.
|
||||||
|
@ -142,11 +137,23 @@ struct qed_chain {
|
||||||
/* Total number of elements [for entire chain] */
|
/* Total number of elements [for entire chain] */
|
||||||
u32 size;
|
u32 size;
|
||||||
|
|
||||||
u8 intended_use;
|
enum qed_chain_use_mode intended_use;
|
||||||
|
|
||||||
bool b_external_pbl;
|
bool b_external_pbl;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct qed_chain_init_params {
|
||||||
|
enum qed_chain_mode mode;
|
||||||
|
enum qed_chain_use_mode intended_use;
|
||||||
|
enum qed_chain_cnt_type cnt_type;
|
||||||
|
|
||||||
|
u32 num_elems;
|
||||||
|
size_t elem_size;
|
||||||
|
|
||||||
|
void *ext_pbl_virt;
|
||||||
|
dma_addr_t ext_pbl_phys;
|
||||||
|
};
|
||||||
|
|
||||||
#define QED_CHAIN_PAGE_SIZE 0x1000
|
#define QED_CHAIN_PAGE_SIZE 0x1000
|
||||||
|
|
||||||
#define ELEMS_PER_PAGE(elem_size) \
|
#define ELEMS_PER_PAGE(elem_size) \
|
||||||
|
|
|
@ -948,13 +948,8 @@ struct qed_common_ops {
|
||||||
u8 dp_level);
|
u8 dp_level);
|
||||||
|
|
||||||
int (*chain_alloc)(struct qed_dev *cdev,
|
int (*chain_alloc)(struct qed_dev *cdev,
|
||||||
enum qed_chain_use_mode intended_use,
|
struct qed_chain *chain,
|
||||||
enum qed_chain_mode mode,
|
struct qed_chain_init_params *params);
|
||||||
enum qed_chain_cnt_type cnt_type,
|
|
||||||
u32 num_elems,
|
|
||||||
size_t elem_size,
|
|
||||||
struct qed_chain *p_chain,
|
|
||||||
struct qed_chain_ext_pbl *ext_pbl);
|
|
||||||
|
|
||||||
void (*chain_free)(struct qed_dev *cdev,
|
void (*chain_free)(struct qed_dev *cdev,
|
||||||
struct qed_chain *p_chain);
|
struct qed_chain *p_chain);
|
||||||
|
|
Loading…
Reference in a new issue