Skip to content

Commit 42f7afa

Browse files
Rakesh KudurumallaJerin Jacob
authored andcommitted
drivers: net/cnxk: enable CPT CQ for outbound traffic
Enable CPT CQ in cpt instruction to read outbound error packets from CQ Signed-off-by: Rakesh Kudurumalla <[email protected]>
1 parent 74c0e31 commit 42f7afa

File tree

7 files changed

+46
-9
lines changed

7 files changed

+46
-9
lines changed

doc/guides/nics/cnxk.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -678,6 +678,18 @@ Runtime Config Options for inline device
678678
With the above configuration, driver would poll for soft expiry events every
679679
1000 usec.
680680

681+
- ``CPT completion queue enable for outbound expiry packet`` (default ``0``)
682+
683+
CPT completion queue can be enabled for outbound expiry packet processing
684+
by specifying ``cpt_cq_ena`` ``devargs`` parameter.
685+
686+
For example::
687+
688+
-a 0002:1d:00.0,cpt_cq_ena=1
689+
690+
With the above configuration, CPT completion queue will be enabled for
691+
outbound expiry packet handling on the inline device.
692+
681693
- ``Rx Inject Enable inbound inline IPsec for second pass`` (default ``0``)
682694

683695
Rx packet inject feature for inbound inline IPsec processing can be enabled

drivers/common/cnxk/roc_nix_inl.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2563,3 +2563,21 @@ roc_nix_inl_custom_meta_pool_cb_register(roc_nix_inl_custom_meta_pool_cb_t cb)
25632563
{
25642564
custom_meta_pool_cb = cb;
25652565
}
2566+
2567+
uint8_t
2568+
roc_nix_inl_is_cq_ena(struct roc_nix *roc_nix)
2569+
{
2570+
struct idev_cfg *idev = idev_get_cfg();
2571+
struct nix_inl_dev *inl_dev;
2572+
2573+
PLT_SET_USED(roc_nix);
2574+
if (idev != NULL) {
2575+
inl_dev = idev->nix_inl_dev;
2576+
if (inl_dev)
2577+
return inl_dev->cpt_cq_ena;
2578+
else
2579+
return 0;
2580+
} else {
2581+
return 0;
2582+
}
2583+
}

drivers/common/cnxk/roc_nix_inl.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ int __roc_api roc_nix_inl_ctx_write(struct roc_nix *roc_nix, void *sa_dptr,
213213
void __roc_api roc_nix_inl_outb_cpt_lfs_dump(struct roc_nix *roc_nix, FILE *file);
214214
uint64_t __roc_api roc_nix_inl_eng_caps_get(struct roc_nix *roc_nix);
215215
void *__roc_api roc_nix_inl_dev_qptr_get(uint8_t qid);
216+
uint8_t __roc_api roc_nix_inl_is_cq_ena(struct roc_nix *roc_nix);
216217

217218
enum roc_nix_cpt_lf_stats_type {
218219
ROC_NIX_CPT_LF_STATS_INL_DEV,

drivers/common/cnxk/roc_platform_base_symbols.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,7 @@ RTE_EXPORT_INTERNAL_SYMBOL(roc_nix_inl_eng_caps_get)
281281
RTE_EXPORT_INTERNAL_SYMBOL(roc_nix_inl_custom_meta_pool_cb_register)
282282
RTE_EXPORT_INTERNAL_SYMBOL(roc_nix_inl_dev_xaq_realloc)
283283
RTE_EXPORT_INTERNAL_SYMBOL(roc_nix_inl_dev_qptr_get)
284+
RTE_EXPORT_INTERNAL_SYMBOL(roc_nix_inl_is_cq_ena)
284285
RTE_EXPORT_INTERNAL_SYMBOL(roc_nix_inl_dev_stats_get)
285286
RTE_EXPORT_INTERNAL_SYMBOL(roc_nix_inl_dev_stats_reset)
286287
RTE_EXPORT_INTERNAL_SYMBOL(roc_nix_inl_dev_init)

drivers/net/cnxk/cn20k_ethdev_sec.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -664,6 +664,9 @@ cn20k_eth_sec_outb_sa_misc_fill(struct roc_nix *roc_nix, struct roc_ow_ipsec_out
664664
{
665665
uint64_t *ring_base, ring_addr;
666666

667+
if (roc_nix_inl_is_cq_ena(roc_nix))
668+
goto done;
669+
667670
if (ipsec_xfrm->life.bytes_soft_limit | ipsec_xfrm->life.packets_soft_limit) {
668671
ring_base = roc_nix_inl_outb_ring_base_get(roc_nix);
669672
if (ring_base == NULL)
@@ -674,6 +677,7 @@ cn20k_eth_sec_outb_sa_misc_fill(struct roc_nix *roc_nix, struct roc_ow_ipsec_out
674677
sa->ctx.err_ctl.s.address = ring_addr >> 3;
675678
sa->w0.s.ctx_id = ((uintptr_t)sa_cptr >> 51) & 0x1ff;
676679
}
680+
done:
677681
return 0;
678682
}
679683

@@ -909,8 +913,7 @@ cn20k_eth_sec_session_create(void *device, struct rte_security_session_conf *con
909913
sess_priv.chksum =
910914
(!ipsec->options.ip_csum_enable << 1 | !ipsec->options.l4_csum_enable);
911915
sess_priv.dec_ttl = ipsec->options.dec_ttl;
912-
if (roc_feature_nix_has_inl_ipsec_mseg() && dev->outb.cpt_eng_caps & BIT_ULL(35))
913-
sess_priv.nixtx_off = 1;
916+
sess_priv.cpt_cq_ena = roc_nix_inl_is_cq_ena(&dev->nix);
914917

915918
/* Pointer from eth_sec -> outb_sa */
916919
eth_sec->sa = outb_sa;
@@ -1106,9 +1109,8 @@ cn20k_eth_sec_session_update(void *device, struct rte_security_session *sess,
11061109
sess_priv.chksum =
11071110
(!ipsec->options.ip_csum_enable << 1 | !ipsec->options.l4_csum_enable);
11081111
sess_priv.dec_ttl = ipsec->options.dec_ttl;
1109-
if (roc_feature_nix_has_inl_ipsec_mseg() && dev->outb.cpt_eng_caps & BIT_ULL(35))
1110-
sess_priv.nixtx_off = 1;
11111112

1113+
sess_priv.cpt_cq_ena = roc_nix_inl_is_cq_ena(&dev->nix);
11121114
rc = roc_nix_inl_ctx_write(&dev->nix, outb_sa_dptr, eth_sec->sa, eth_sec->inb,
11131115
sizeof(struct roc_ow_ipsec_outb_sa));
11141116
if (rc)

drivers/net/cnxk/cn20k_rxtx.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ struct __rte_packed_begin cn20k_sec_sess_priv {
106106
uint16_t partial_len : 10;
107107
uint16_t chksum : 2;
108108
uint16_t dec_ttl : 1;
109-
uint16_t nixtx_off : 1;
109+
uint16_t cpt_cq_ena : 1;
110110
uint16_t rsvd : 2;
111111
};
112112

drivers/net/cnxk/cn20k_tx.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -444,14 +444,15 @@ cn20k_nix_prep_sec_vec(struct rte_mbuf *m, uint64x2_t *cmd0, uint64x2_t *cmd1,
444444
uint32_t pkt_len, dlen_adj, rlen;
445445
uint8_t l3l4type, chksum;
446446
uint64x2_t cmd01, cmd23;
447+
uint64_t sa, cpt_cq_ena;
447448
uint8_t l2_len, l3_len;
448449
uintptr_t dptr, nixtx;
449450
uint64_t ucode_cmd[4];
450451
uint64_t *laddr, w0;
451452
uint16_t tag;
452-
uint64_t sa;
453453

454454
sess_priv.u64 = *rte_security_dynfield(m);
455+
cpt_cq_ena = sess_priv.cpt_cq_ena;
455456

456457
if (flags & NIX_TX_NEED_SEND_HDR_W1) {
457458
/* Extract l3l4type either from il3il4type or ol3ol4type */
@@ -530,7 +531,7 @@ cn20k_nix_prep_sec_vec(struct rte_mbuf *m, uint64x2_t *cmd0, uint64x2_t *cmd1,
530531
cmd01 = vdupq_n_u64(0);
531532
cmd01 = vsetq_lane_u64(w0, cmd01, 0);
532533
/* CPT_RES_S is 16B above NIXTX */
533-
cmd01 = vsetq_lane_u64(nixtx - 16, cmd01, 1);
534+
cmd01 = vsetq_lane_u64((nixtx - 16) | cpt_cq_ena << 63, cmd01, 1);
534535

535536
/* Return nixtx addr */
536537
*nixtx_addr = nixtx;
@@ -577,15 +578,16 @@ cn20k_nix_prep_sec(struct rte_mbuf *m, uint64_t *cmd, uintptr_t *nixtx_addr, uin
577578
uint8_t l3l4type, chksum;
578579
uint64x2_t cmd01, cmd23;
579580
union nix_send_sg_s *sg;
581+
uint64_t sa, cpt_cq_ena;
580582
uint8_t l2_len, l3_len;
581583
uintptr_t dptr, nixtx;
582584
uint64_t ucode_cmd[4];
583585
uint64_t *laddr, w0;
584586
uint16_t tag;
585-
uint64_t sa;
586587

587588
/* Move to our line from base */
588589
sess_priv.u64 = *rte_security_dynfield(m);
590+
cpt_cq_ena = sess_priv.cpt_cq_ena;
589591
send_hdr = (struct nix_send_hdr_s *)cmd;
590592
if (flags & NIX_TX_NEED_EXT_HDR)
591593
sg = (union nix_send_sg_s *)&cmd[4];
@@ -668,7 +670,8 @@ cn20k_nix_prep_sec(struct rte_mbuf *m, uint64_t *cmd, uintptr_t *nixtx_addr, uin
668670
cmd01 = vdupq_n_u64(0);
669671
cmd01 = vsetq_lane_u64(w0, cmd01, 0);
670672
/* CPT_RES_S is 16B above NIXTX */
671-
cmd01 = vsetq_lane_u64(nixtx - 16, cmd01, 1);
673+
/* CQ_ENA for cpt */
674+
cmd01 = vsetq_lane_u64((nixtx - 16) | cpt_cq_ena << 63, cmd01, 1);
672675

673676
/* Return nixtx addr */
674677
*nixtx_addr = nixtx;

0 commit comments

Comments
 (0)