net/cnxk: add SoC specific PTP timestamp read
[dpdk.git] / drivers / event / cnxk / cn10k_worker.h
index cfe729c..0226896 100644 (file)
@@ -92,12 +92,16 @@ cn10k_sso_hws_forward_event(struct cn10k_sso_hws *ws,
 }
 
 static __rte_always_inline void
-cn10k_wqe_to_mbuf(uint64_t wqe, const uint64_t mbuf, uint8_t port_id,
+cn10k_wqe_to_mbuf(uint64_t wqe, const uint64_t __mbuf, uint8_t port_id,
                  const uint32_t tag, const uint32_t flags,
                  const void *const lookup_mem)
 {
        const uint64_t mbuf_init = 0x100010000ULL | RTE_PKTMBUF_HEADROOM |
                                   (flags & NIX_RX_OFFLOAD_TSTAMP_F ? 8 : 0);
+       struct rte_mbuf *mbuf = (struct rte_mbuf *)__mbuf;
+
+       /* Mark mempool obj as "get" as it is alloc'ed by NIX */
+       RTE_MEMPOOL_CHECK_COOKIES(mbuf->pool, (void **)&mbuf, 1, 1);
 
        cn10k_nix_cqe_to_mbuf((struct nix_cqe_hdr_s *)wqe, tag,
                              (struct rte_mbuf *)mbuf, lookup_mem,
@@ -159,6 +163,9 @@ cn10k_process_vwqe(uintptr_t vwqe, uint16_t port_id, const uint32_t flags,
                mbuf = (struct rte_mbuf *)((char *)cqe -
                                           sizeof(struct rte_mbuf));
 
+               /* Mark mempool obj as "get" as it is alloc'ed by NIX */
+               RTE_MEMPOOL_CHECK_COOKIES(mbuf->pool, (void **)&mbuf, 1, 1);
+
                /* Translate meta to mbuf */
                if (flags & NIX_RX_OFFLOAD_SECURITY_F) {
                        const uint64_t cq_w1 = *((const uint64_t *)cqe + 1);
@@ -172,9 +179,8 @@ cn10k_process_vwqe(uintptr_t vwqe, uint16_t port_id, const uint32_t flags,
                /* Extracting tstamp, if PTP enabled*/
                tstamp_ptr = *(uint64_t *)(((struct nix_wqe_hdr_s *)cqe) +
                                           CNXK_SSO_WQE_SG_PTR);
-               cnxk_nix_mbuf_to_tstamp((struct rte_mbuf *)mbuf, tstamp,
+               cn10k_nix_mbuf_to_tstamp((struct rte_mbuf *)mbuf, tstamp,
                                        flags & NIX_RX_OFFLOAD_TSTAMP_F,
-                                       flags & NIX_RX_MULTI_SEG_F,
                                        (uint64_t *)tstamp_ptr);
                wqe[0] = (uint64_t *)mbuf;
                non_vec--;
@@ -263,10 +269,9 @@ cn10k_sso_hws_get_work(struct cn10k_sso_hws *ws, struct rte_event *ev,
                        tstamp_ptr = *(uint64_t *)(((struct nix_wqe_hdr_s *)
                                                            gw.u64[1]) +
                                                   CNXK_SSO_WQE_SG_PTR);
-                       cnxk_nix_mbuf_to_tstamp((struct rte_mbuf *)mbuf,
+                       cn10k_nix_mbuf_to_tstamp((struct rte_mbuf *)mbuf,
                                                ws->tstamp,
                                                flags & NIX_RX_OFFLOAD_TSTAMP_F,
-                                               flags & NIX_RX_MULTI_SEG_F,
                                                (uint64_t *)tstamp_ptr);
                        gw.u64[1] = mbuf;
                } else if (CNXK_EVENT_TYPE_FROM_TAG(gw.u64[0]) ==
@@ -280,6 +285,10 @@ cn10k_sso_hws_get_work(struct cn10k_sso_hws *ws, struct rte_event *ev,
                        *(uint64_t *)gw.u64[1] = (uint64_t)vwqe_hdr;
                        cn10k_process_vwqe(gw.u64[1], port, flags, lookup_mem,
                                           ws->tstamp, ws->lmt_base);
+                       /* Mark vector mempool object as get */
+                       RTE_MEMPOOL_CHECK_COOKIES(
+                               rte_mempool_from_obj((void *)gw.u64[1]),
+                               (void **)&gw.u64[1], 1, 1);
                }
        }
 
@@ -470,6 +479,14 @@ cn10k_sso_hws_xtract_meta(struct rte_mbuf *m, const uint64_t *txq_data)
                           (BIT_ULL(48) - 1));
 }
 
+static __rte_always_inline void
+cn10k_sso_txq_fc_wait(const struct cn10k_eth_txq *txq)
+{
+       while ((uint64_t)txq->nb_sqb_bufs_adj <=
+              __atomic_load_n(txq->fc_mem, __ATOMIC_RELAXED))
+               ;
+}
+
 static __rte_always_inline void
 cn10k_sso_tx_one(struct cn10k_sso_hws *ws, struct rte_mbuf *m, uint64_t *cmd,
                 uint16_t lmt_id, uintptr_t lmt_addr, uint8_t sched_type,
@@ -517,6 +534,7 @@ cn10k_sso_tx_one(struct cn10k_sso_hws *ws, struct rte_mbuf *m, uint64_t *cmd,
        if (!CNXK_TAG_IS_HEAD(ws->gw_rdata) && !sched_type)
                ws->gw_rdata = roc_sso_hws_head_wait(ws->base);
 
+       cn10k_sso_txq_fc_wait(txq);
        roc_lmt_submit_steorl(lmt_id, pa);
 }
 
@@ -577,7 +595,6 @@ cn10k_sso_hws_event_tx(struct cn10k_sso_hws *ws, struct rte_event *ev,
        struct cn10k_eth_txq *txq;
        struct rte_mbuf *m;
        uintptr_t lmt_addr;
-       uint16_t ref_cnt;
        uint16_t lmt_id;
 
        lmt_addr = ws->lmt_base;
@@ -607,17 +624,9 @@ cn10k_sso_hws_event_tx(struct cn10k_sso_hws *ws, struct rte_event *ev,
        }
 
        m = ev->mbuf;
-       ref_cnt = m->refcnt;
        cn10k_sso_tx_one(ws, m, cmd, lmt_id, lmt_addr, ev->sched_type, txq_data,
                         flags);
 
-       if (flags & NIX_TX_OFFLOAD_MBUF_NOFF_F) {
-               if (ref_cnt > 1)
-                       return 1;
-       }
-
-       cnxk_sso_hws_swtag_flush(ws->base + SSOW_LF_GWS_TAG,
-                                ws->base + SSOW_LF_GWS_OP_SWTAG_FLUSH);
        return 1;
 }