Skip to content

Commit f37ef3d

Browse files
Rakesh KudurumallaJerin Jacob
authored andcommitted
common/cnxk: add routines to operate CPT CQ
Added routines to enable, disable and initialize CPT CQ if cpt_cq_ena is set Signed-off-by: Rakesh Kudurumalla <[email protected]>
1 parent 8063162 commit f37ef3d

File tree

4 files changed

+85
-2
lines changed

4 files changed

+85
-2
lines changed

drivers/common/cnxk/roc_cpt.c

Lines changed: 73 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#define CPT_LF_MAX_NB_DESC 128000
2525
#define CPT_LF_DEFAULT_NB_DESC 1024
2626
#define CPT_LF_FC_MIN_THRESHOLD 32
27+
#define CQ_ENTRY_SIZE_UNIT 32
2728

2829
static struct cpt_int_cb {
2930
roc_cpt_int_misc_cb_t cb;
@@ -687,6 +688,37 @@ cpt_get_blkaddr(struct dev *dev)
687688
return reg & 0x1FFULL ? RVU_BLOCK_ADDR_CPT1 : RVU_BLOCK_ADDR_CPT0;
688689
}
689690

691+
int
692+
cpt_lf_cq_init(struct roc_cpt_lf *lf)
693+
{
694+
union cpt_lf_cq_size lf_cq_size = {.u = 0x0};
695+
union cpt_lf_cq_base lf_cq_base = {.u = 0x0};
696+
uint8_t max_cq_entry_size = 0x3;
697+
uintptr_t addr;
698+
uint32_t len;
699+
700+
if (!lf->cq_size || lf->cq_entry_size > max_cq_entry_size)
701+
return -EINVAL;
702+
703+
/* Disable CPT completion queue */
704+
roc_cpt_cq_disable(lf);
705+
706+
/* Set command queue base address */
707+
len = PLT_ALIGN(lf->cq_size * (CQ_ENTRY_SIZE_UNIT << lf->cq_entry_size), ROC_ALIGN);
708+
lf->cq_vaddr = plt_zmalloc(len, ROC_ALIGN);
709+
if (lf->cq_vaddr == NULL)
710+
return -ENOMEM;
711+
712+
addr = (uintptr_t)lf->cq_vaddr;
713+
714+
lf_cq_base.s.addr = addr >> 7;
715+
plt_write64(lf_cq_base.u, lf->rbase + CPT_LF_CQ_BASE);
716+
lf_cq_size.s.size = PLT_ALIGN(len, ROC_ALIGN);
717+
plt_write64(lf_cq_size.u, lf->rbase + CPT_LF_CQ_SIZE);
718+
719+
return 0;
720+
}
721+
690722
int
691723
cpt_lf_init(struct roc_cpt_lf *lf, bool skip_register_irq)
692724
{
@@ -713,14 +745,22 @@ cpt_lf_init(struct roc_cpt_lf *lf, bool skip_register_irq)
713745
/* Initialize instruction queue */
714746
cpt_iq_init(lf);
715747

748+
if (lf->cpt_cq_ena) {
749+
rc = cpt_lf_cq_init(lf);
750+
if (rc)
751+
goto disable_iq;
752+
}
753+
716754
if (!skip_register_irq) {
717755
rc = cpt_lf_register_irqs(lf, cpt_lf_misc_irq, cpt_lf_done_irq);
718756
if (rc)
719-
goto disable_iq;
757+
goto disable_cq;
720758
}
721759

722760
return 0;
723761

762+
disable_cq:
763+
cpt_lf_cq_fini(lf);
724764
disable_iq:
725765
roc_cpt_iq_disable(lf);
726766
plt_free(iq_mem);
@@ -954,6 +994,7 @@ cpt_lf_fini(struct roc_cpt_lf *lf, bool skip_register_irq)
954994
if (!skip_register_irq)
955995
cpt_lf_unregister_irqs(lf, cpt_lf_misc_irq, cpt_lf_done_irq);
956996

997+
cpt_lf_cq_fini(lf);
957998
/* Disable IQ */
958999
roc_cpt_iq_disable(lf);
9591000
roc_cpt_iq_reset(lf);
@@ -963,6 +1004,17 @@ cpt_lf_fini(struct roc_cpt_lf *lf, bool skip_register_irq)
9631004
lf->iq_vaddr = NULL;
9641005
}
9651006

1007+
void
1008+
cpt_lf_cq_fini(struct roc_cpt_lf *lf)
1009+
{
1010+
if (!lf->cpt_cq_ena)
1011+
return;
1012+
1013+
roc_cpt_cq_disable(lf);
1014+
plt_free(lf->cq_vaddr);
1015+
lf->cq_vaddr = NULL;
1016+
}
1017+
9661018
void
9671019
roc_cpt_lf_reset(struct roc_cpt_lf *lf)
9681020
{
@@ -1074,6 +1126,26 @@ roc_cpt_eng_grp_add(struct roc_cpt *roc_cpt, enum cpt_eng_type eng_type)
10741126
return ret;
10751127
}
10761128

1129+
void
1130+
roc_cpt_cq_enable(struct roc_cpt_lf *lf)
1131+
{
1132+
union cpt_lf_cq_ctl lf_cq_ctl = {.u = 0x0};
1133+
1134+
lf_cq_ctl.s.ena = 1;
1135+
lf_cq_ctl.s.dq_ack_ena = lf->dq_ack_ena;
1136+
lf_cq_ctl.s.entry_size = lf->cq_entry_size;
1137+
lf_cq_ctl.s.cq_all = lf->cq_all;
1138+
plt_write64(lf_cq_ctl.u, lf->rbase + CPT_LF_CQ_CTL);
1139+
}
1140+
1141+
void
1142+
roc_cpt_cq_disable(struct roc_cpt_lf *lf)
1143+
{
1144+
union cpt_lf_cq_ctl lf_cq_ctl = {.u = 0x0};
1145+
1146+
plt_write64(lf_cq_ctl.u, lf->rbase + CPT_LF_CQ_CTL);
1147+
}
1148+
10771149
void
10781150
roc_cpt_iq_disable(struct roc_cpt_lf *lf)
10791151
{

drivers/common/cnxk/roc_cpt.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,16 @@ struct roc_cpt_lf {
152152
/* Input parameters */
153153
uint16_t lf_id;
154154
uint32_t nb_desc;
155+
bool dq_ack_ena;
156+
bool cq_all;
157+
bool cpt_cq_ena;
158+
uint8_t cq_entry_size;
159+
uint32_t cq_size;
155160
/* End of Input parameters */
156161
struct plt_pci_device *pci_dev;
157162
struct dev *dev;
158163
struct roc_cpt *roc_cpt;
164+
uint16_t *cq_vaddr;
159165
uintptr_t rbase;
160166
uintptr_t lmt_base;
161167
uint16_t msixoff;
@@ -231,6 +237,8 @@ int __roc_api roc_cpt_afs_print(struct roc_cpt *roc_cpt);
231237
int __roc_api roc_cpt_lfs_print(struct roc_cpt *roc_cpt);
232238
void __roc_api roc_cpt_iq_disable(struct roc_cpt_lf *lf);
233239
void __roc_api roc_cpt_iq_enable(struct roc_cpt_lf *lf);
240+
void __roc_api roc_cpt_cq_disable(struct roc_cpt_lf *lf);
241+
void __roc_api roc_cpt_cq_enable(struct roc_cpt_lf *lf);
234242
int __roc_api roc_cpt_lmtline_init(struct roc_cpt *roc_cpt, struct roc_cpt_lmtline *lmtline,
235243
int lf_id, bool is_dual);
236244

drivers/common/cnxk/roc_cpt_priv.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ int cpt_lf_init(struct roc_cpt_lf *lf, bool skip_register_irq);
3030
void cpt_lf_fini(struct roc_cpt_lf *lf, bool skip_register_irq);
3131
int cpt_lf_register_irqs(struct roc_cpt_lf *lf, misc_irq_cb_t misc_cb, done_irq_cb_t done_cb);
3232
void cpt_lf_unregister_irqs(struct roc_cpt_lf *lf, misc_irq_cb_t misc_cb, done_irq_cb_t done_cb);
33-
void cpt_lf_cq_init(struct roc_cpt_lf *lf);
33+
int cpt_lf_cq_init(struct roc_cpt_lf *lf);
34+
void cpt_lf_cq_fini(struct roc_cpt_lf *lf);
3435
void cpt_lf_misc_irq(void *params);
3536

3637
int cpt_lf_outb_cfg(struct dev *dev, uint16_t sso_pf_func, uint16_t nix_pf_func,

drivers/common/cnxk/roc_platform_base_symbols.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ RTE_EXPORT_INTERNAL_SYMBOL(roc_cpt_lf_ctx_reload)
5050
RTE_EXPORT_INTERNAL_SYMBOL(roc_cpt_lf_reset)
5151
RTE_EXPORT_INTERNAL_SYMBOL(roc_cpt_lf_fini)
5252
RTE_EXPORT_INTERNAL_SYMBOL(roc_cpt_dev_fini)
53+
RTE_EXPORT_INTERNAL_SYMBOL(roc_cpt_cq_disable)
54+
RTE_EXPORT_INTERNAL_SYMBOL(roc_cpt_cq_enable)
5355
RTE_EXPORT_INTERNAL_SYMBOL(roc_cpt_dev_clear)
5456
RTE_EXPORT_INTERNAL_SYMBOL(roc_cpt_eng_grp_add)
5557
RTE_EXPORT_INTERNAL_SYMBOL(roc_cpt_iq_disable)

0 commit comments

Comments
 (0)