Skip to content

Commit 74c0e31

Browse files
Rakesh KudurumallaJerin Jacob
authored andcommitted
drivers: net/cnxk: handle soft expiry support
Add routines to handle soft expiry for outbound packets using CPT CQ mechanism. Added devargs support to inline device to use CPT CQ. Signed-off-by: Rakesh Kudurumalla <[email protected]>
1 parent f37ef3d commit 74c0e31

File tree

10 files changed

+221
-59
lines changed

10 files changed

+221
-59
lines changed

drivers/common/cnxk/roc_features.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,4 +120,9 @@ roc_feature_nix_has_plain_pkt_reassembly(void)
120120
return roc_model_is_cn20k();
121121
}
122122

123+
static inline bool
124+
roc_feature_nix_has_cpt_cq_support(void)
125+
{
126+
return roc_model_is_cn20k();
127+
}
123128
#endif

drivers/common/cnxk/roc_nix_inl.h

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,19 @@
4141
#define ROC_NIX_INL_REAS_ZOMBIE_LIMIT 0xFFF
4242
#define ROC_NIX_INL_REAS_ZOMBIE_THRESHOLD 10
4343

44+
enum nix_inl_event_type {
45+
NIX_INL_CPT_CQ = 1,
46+
NIX_INL_SSO,
47+
NIX_INL_SOFT_EXPIRY_THRD,
48+
};
49+
50+
enum comp_ptr {
51+
WQE_PTR_CPTR,
52+
CPTR_WQE_PTR,
53+
WQE_PTR_ANTI_REPLAY,
54+
CPTR_ANTI_REPLAY,
55+
};
56+
4457
static inline struct roc_ie_on_inb_sa *
4558
roc_nix_inl_on_ipsec_inb_sa(uintptr_t base, uint64_t idx)
4659
{
@@ -70,8 +83,8 @@ roc_nix_inl_on_ipsec_outb_sa_sw_rsvd(void *sa)
7083
}
7184

7285
/* Inline device SSO Work callback */
73-
typedef void (*roc_nix_inl_sso_work_cb_t)(uint64_t *gw, void *args,
74-
uint32_t soft_exp_event);
86+
typedef void (*roc_nix_inl_sso_work_cb_t)(uint64_t *gw, void *args, enum nix_inl_event_type type,
87+
void *cq_s, uint32_t port_id);
7588

7689
typedef int (*roc_nix_inl_meta_pool_cb_t)(uint64_t *aura_handle, uintptr_t *mpool,
7790
uint32_t blk_sz, uint32_t nb_bufs, bool destroy,
@@ -93,6 +106,7 @@ struct roc_nix_inl_dev {
93106
uint8_t spb_drop_pc;
94107
uint8_t lpb_drop_pc;
95108
uint32_t soft_exp_poll_freq; /* Polling disabled if 0 */
109+
uint8_t cpt_cq_enable;
96110
uint32_t nb_meta_bufs;
97111
uint32_t meta_buf_sz;
98112
uint32_t max_ipsec_rules;

drivers/common/cnxk/roc_nix_inl_dev.c

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,14 @@ nix_inl_dev_pffunc_get(void)
3737
}
3838

3939
static void
40-
nix_inl_selftest_work_cb(uint64_t *gw, void *args, uint32_t soft_exp_event)
40+
nix_inl_selftest_work_cb(uint64_t *gw, void *args, enum nix_inl_event_type type, void *cq_s,
41+
uint32_t port_id)
4142
{
4243
uintptr_t work = gw[1];
4344

44-
(void)soft_exp_event;
45+
(void)type;
46+
(void)cq_s;
47+
(void)port_id;
4548
*((uintptr_t *)args + (gw[0] & 0x1)) = work;
4649

4750
plt_atomic_thread_fence(__ATOMIC_ACQ_REL);
@@ -476,8 +479,10 @@ nix_inl_cpt_setup(struct nix_inl_dev *inl_dev, bool inl_dev_sso)
476479

477480
return 0;
478481
lf_fini:
479-
for (i = 0; i < inl_dev->nb_cptlf; i++)
480-
cpt_lf_fini(&inl_dev->cpt_lf[i], false);
482+
for (i = 0; i < inl_dev->nb_cptlf; i++) {
483+
struct roc_cpt_lf *lf = &inl_dev->cpt_lf[i];
484+
cpt_lf_fini(lf, lf->cpt_cq_ena);
485+
}
481486
lf_free:
482487
rc |= cpt_lfs_free(dev);
483488
return rc;
@@ -500,9 +505,12 @@ nix_inl_cpt_release(struct nix_inl_dev *inl_dev)
500505
/* TODO: Wait for CPT/RXC queue to drain */
501506

502507
/* Cleanup CPT LF queue */
503-
for (i = 0; i < inl_dev->nb_cptlf; i++)
504-
cpt_lf_fini(&inl_dev->cpt_lf[i], false);
505-
508+
for (i = 0; i < inl_dev->nb_cptlf; i++) {
509+
struct roc_cpt_lf *lf = &inl_dev->cpt_lf[i];
510+
cpt_lf_fini(lf, lf->cpt_cq_ena);
511+
if (lf->cpt_cq_ena)
512+
cpt_lf_unregister_irqs(lf, cpt_lf_misc_irq, nix_inl_cpt_done_irq);
513+
}
506514
/* Free LF resources */
507515
rc = cpt_lfs_free(dev);
508516
if (!rc) {
@@ -1162,7 +1170,7 @@ inl_outb_soft_exp_poll(struct nix_inl_dev *inl_dev, uint32_t ring_idx)
11621170

11631171
if (sa != NULL) {
11641172
uint64_t tmp = ~(uint32_t)0x0;
1165-
inl_dev->work_cb(&tmp, sa, (port_id << 8) | 0x1);
1173+
inl_dev->work_cb(&tmp, sa, NIX_INL_SOFT_EXPIRY_THRD, NULL, port_id);
11661174
__atomic_store_n(ring_base + tail_l + 1, 0ULL,
11671175
__ATOMIC_RELAXED);
11681176
__atomic_fetch_add((uint32_t *)ring_base, 1,
@@ -1381,6 +1389,7 @@ roc_nix_inl_dev_init(struct roc_nix_inl_dev *roc_inl_dev)
13811389
inl_dev->nb_meta_bufs = roc_inl_dev->nb_meta_bufs;
13821390
inl_dev->meta_buf_sz = roc_inl_dev->meta_buf_sz;
13831391
inl_dev->soft_exp_poll_freq = roc_inl_dev->soft_exp_poll_freq;
1392+
inl_dev->cpt_cq_ena = roc_inl_dev->cpt_cq_enable;
13841393
inl_dev->custom_inb_sa = roc_inl_dev->custom_inb_sa;
13851394
inl_dev->nix_inb_q_bpid = -1;
13861395
inl_dev->nb_cptlf = 1;
@@ -1401,6 +1410,10 @@ roc_nix_inl_dev_init(struct roc_nix_inl_dev *roc_inl_dev)
14011410
inl_dev->nb_cptlf++;
14021411
}
14031412

1413+
if (roc_feature_nix_has_cpt_cq_support() && inl_dev->cpt_cq_ena) {
1414+
inl_dev->soft_exp_poll_freq = 0;
1415+
inl_dev->set_soft_exp_poll = 0;
1416+
}
14041417
/* Attach inline inbound CPT LF to NIX has multi queue support */
14051418
if (roc_feature_nix_has_inl_multi_queue() && roc_inl_dev->nb_inb_cptlfs) {
14061419
inl_dev->nb_inb_cptlfs = roc_inl_dev->nb_inb_cptlfs;

drivers/common/cnxk/roc_nix_inl_dev_irq.c

Lines changed: 74 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ nix_inl_sso_work_cb(struct nix_inl_dev *inl_dev)
3232
/* Do we have any work? */
3333
if (work) {
3434
if (inl_dev->work_cb)
35-
inl_dev->work_cb(gw.u64, inl_dev->cb_args, false);
35+
inl_dev->work_cb(gw.u64, inl_dev->cb_args, NIX_INL_SSO, NULL, false);
3636
else
3737
plt_warn("Undelivered inl dev work gw0: %p gw1: %p",
3838
(void *)gw.u64[0], (void *)gw.u64[1]);
@@ -45,6 +45,60 @@ nix_inl_sso_work_cb(struct nix_inl_dev *inl_dev)
4545
plt_atomic_thread_fence(__ATOMIC_ACQ_REL);
4646
}
4747

48+
static void
49+
nix_inl_cpt_cq_cb(struct roc_cpt_lf *lf)
50+
{
51+
struct roc_nix *roc_nix = (struct roc_nix *)lf->dev->roc_nix;
52+
struct idev_cfg *idev = idev_get_cfg();
53+
uint32_t port_id = roc_nix->port_id;
54+
struct nix_inl_dev *inl_dev = NULL;
55+
struct roc_ow_ipsec_outb_sa *sa;
56+
union cpt_lf_cq_base cq_base;
57+
union cpt_lf_cq_ptr cq_ptr;
58+
struct cpt_cq_s *cq_s;
59+
uint8_t fmt_msk = 0x3;
60+
uint64_t nq_ptr;
61+
uint32_t count;
62+
uint64_t i;
63+
64+
if (idev)
65+
inl_dev = idev->nix_inl_dev;
66+
67+
if (!inl_dev) {
68+
plt_nix_dbg("Inline Device could not be detected");
69+
return;
70+
}
71+
72+
cq_base.u = plt_read64(lf->rbase + CPT_LF_CQ_BASE);
73+
cq_ptr.u = plt_read64(lf->rbase + CPT_LF_CQ_PTR);
74+
count = cq_ptr.s.count;
75+
76+
nq_ptr = (((cq_base.s.addr << 7)) + ((cq_ptr.s.nq_ptr - count) << 5));
77+
cq_s = (struct cpt_cq_s *)nq_ptr;
78+
79+
for (i = 0; i < count; i++) {
80+
if (cq_s->w0.s.uc_compcode && cq_s->w0.s.compcode) {
81+
switch (cq_s->w2.s.fmt & fmt_msk) {
82+
case WQE_PTR_CPTR:
83+
sa = (struct roc_ow_ipsec_outb_sa *)cq_s->w1.esn;
84+
break;
85+
case CPTR_WQE_PTR:
86+
sa = (struct roc_ow_ipsec_outb_sa *)cq_s->w3.comp_ptr;
87+
break;
88+
default:
89+
plt_err("Invalid event Received ");
90+
goto done;
91+
}
92+
uint64_t tmp = ~(uint32_t)0x0;
93+
inl_dev->work_cb(&tmp, sa, NIX_INL_CPT_CQ, (void *)cq_s, port_id);
94+
}
95+
done:
96+
cq_s = cq_s + 1;
97+
}
98+
/* Acknowledge the number of completed requests */
99+
plt_write64(count, lf->rbase + CPT_LF_DONE_ACK);
100+
}
101+
48102
static int
49103
nix_inl_nix_reg_dump(struct nix_inl_dev *inl_dev)
50104
{
@@ -102,6 +156,25 @@ nix_inl_sso_hws_irq(void *param)
102156
plt_write64(intr, ssow_base + SSOW_LF_GWS_INT);
103157
}
104158

159+
void
160+
nix_inl_cpt_done_irq(void *param)
161+
{
162+
struct roc_cpt_lf *lf = param;
163+
uint64_t done_wait;
164+
uint64_t intr;
165+
166+
/* Read the number of completed requests */
167+
intr = plt_read64(lf->rbase + CPT_LF_DONE);
168+
if (intr == 0)
169+
return;
170+
171+
done_wait = plt_read64(lf->rbase + CPT_LF_DONE_WAIT);
172+
173+
nix_inl_cpt_cq_cb(lf);
174+
175+
plt_write64(done_wait, lf->rbase + CPT_LF_DONE_WAIT);
176+
}
177+
105178
int
106179
nix_inl_sso_register_irqs(struct nix_inl_dev *inl_dev)
107180
{

drivers/common/cnxk/roc_nix_inl_priv.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ struct nix_inl_dev {
7878
uint32_t soft_exp_poll_freq;
7979
uint64_t *sa_soft_exp_ring;
8080
bool set_soft_exp_poll;
81+
uint8_t cpt_cq_ena;
8182

8283
/* Soft expiry ring bitmap */
8384
struct plt_bitmap *soft_exp_ring_bmap;
@@ -136,6 +137,7 @@ struct nix_inl_dev {
136137
(BIT_ULL(51) | (ROC_CPT_DFLT_ENG_GRP_SE << 48) | \
137138
(ROC_IE_OW_MAJOR_OP_PROCESS_INBOUND_REASS << 32 | ROC_IE_OW_INPLACE_BIT << 32))
138139

140+
void nix_inl_cpt_done_irq(void *params);
139141
int nix_inl_sso_register_irqs(struct nix_inl_dev *inl_dev);
140142
void nix_inl_sso_unregister_irqs(struct nix_inl_dev *inl_dev);
141143

drivers/net/cnxk/cn10k_ethdev.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ void cn10k_eth_set_tx_function(struct rte_eth_dev *eth_dev);
2727
void cn10k_eth_sec_ops_override(void);
2828

2929
/* SSO Work callback */
30-
void cn10k_eth_sec_sso_work_cb(uint64_t *gw, void *args,
31-
uint32_t soft_exp_event);
30+
void cn10k_eth_sec_sso_work_cb(uint64_t *gw, void *args, enum nix_inl_event_type type, void *cq_s,
31+
uint32_t port_id);
3232

3333
#endif /* __CN10K_ETHDEV_H__ */

drivers/net/cnxk/cn10k_ethdev_sec.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,8 @@ cnxk_pktmbuf_free_no_cache(struct rte_mbuf *mbuf)
528528
}
529529

530530
void
531-
cn10k_eth_sec_sso_work_cb(uint64_t *gw, void *args, uint32_t soft_exp_event)
531+
cn10k_eth_sec_sso_work_cb(uint64_t *gw, void *args, enum nix_inl_event_type type, void *cq_s,
532+
uint32_t port_id)
532533
{
533534
struct rte_eth_event_ipsec_desc desc;
534535
struct cn10k_sec_sess_priv sess_priv;
@@ -545,6 +546,7 @@ cn10k_eth_sec_sso_work_cb(uint64_t *gw, void *args, uint32_t soft_exp_event)
545546
uint8_t port;
546547

547548
RTE_SET_USED(args);
549+
RTE_SET_USED(cq_s);
548550

549551
switch ((gw[0] >> 28) & 0xF) {
550552
case RTE_EVENT_TYPE_ETHDEV:
@@ -562,7 +564,7 @@ cn10k_eth_sec_sso_work_cb(uint64_t *gw, void *args, uint32_t soft_exp_event)
562564
}
563565
/* Fall through */
564566
default:
565-
if (soft_exp_event & 0x1) {
567+
if (type == NIX_INL_SOFT_EXPIRY_THRD) {
566568
sa = (struct roc_ot_ipsec_outb_sa *)args;
567569
priv = roc_nix_inl_ot_ipsec_outb_sa_sw_rsvd(sa);
568570
desc.metadata = (uint64_t)priv->userdata;
@@ -572,7 +574,7 @@ cn10k_eth_sec_sso_work_cb(uint64_t *gw, void *args, uint32_t soft_exp_event)
572574
else
573575
desc.subtype =
574576
RTE_ETH_EVENT_IPSEC_SA_BYTE_EXPIRY;
575-
eth_dev = &rte_eth_devices[soft_exp_event >> 8];
577+
eth_dev = &rte_eth_devices[port_id];
576578
rte_eth_dev_callback_process(eth_dev,
577579
RTE_ETH_EVENT_IPSEC, &desc);
578580
} else {

drivers/net/cnxk/cn20k_ethdev.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ void cn20k_eth_set_tx_function(struct rte_eth_dev *eth_dev);
2727
void cn20k_eth_sec_ops_override(void);
2828

2929
/* SSO Work callback */
30-
void cn20k_eth_sec_sso_work_cb(uint64_t *gw, void *args, uint32_t soft_exp_event);
30+
void cn20k_eth_sec_sso_work_cb(uint64_t *gw, void *args, enum nix_inl_event_type type, void *cq_s,
31+
uint32_t port_id);
3132

3233
#endif /* __CN20K_ETHDEV_H__ */

0 commit comments

Comments
 (0)