net/virtio: allocate fake mbuf in Rx queue
[dpdk.git] / drivers / net / octeontx2 / otx2_tx.h
index 3c43170..a97b160 100644 (file)
@@ -363,6 +363,10 @@ otx2_nix_xmit_prepare(struct rte_mbuf *m, uint64_t *cmd, const uint16_t flags)
                         * DF bit = 0 otherwise
                         */
                        send_hdr->w0.df = otx2_nix_prefree_seg(m);
+                       /* Ensuring mbuf fields which got updated in
+                        * otx2_nix_prefree_seg are written before LMTST.
+                        */
+                       rte_io_wmb();
                }
                /* Mark mempool object as "put" since it is freed by NIX */
                if (!send_hdr->w0.df)
@@ -383,6 +387,24 @@ otx2_nix_xmit_one(uint64_t *cmd, void *lmt_addr,
        } while (lmt_status == 0);
 }
 
+static __rte_always_inline void
+otx2_nix_xmit_prep_lmt(uint64_t *cmd, void *lmt_addr, const uint32_t flags)
+{
+       otx2_lmt_mov(lmt_addr, cmd, otx2_nix_tx_ext_subs(flags));
+}
+
+static __rte_always_inline uint64_t
+otx2_nix_xmit_submit_lmt(const rte_iova_t io_addr)
+{
+       return otx2_lmt_submit(io_addr);
+}
+
+static __rte_always_inline uint64_t
+otx2_nix_xmit_submit_lmt_release(const rte_iova_t io_addr)
+{
+       return otx2_lmt_submit_release(io_addr);
+}
+
 static __rte_always_inline uint16_t
 otx2_nix_prepare_mseg(struct rte_mbuf *m, uint64_t *cmd, const uint16_t flags)
 {
@@ -418,13 +440,17 @@ otx2_nix_prepare_mseg(struct rte_mbuf *m, uint64_t *cmd, const uint16_t flags)
                sg_u = sg_u | ((uint64_t)m->data_len << (i << 4));
                *slist = rte_mbuf_data_iova(m);
                /* Set invert df if buffer is not to be freed by H/W */
-               if (flags & NIX_TX_OFFLOAD_MBUF_NOFF_F)
+               if (flags & NIX_TX_OFFLOAD_MBUF_NOFF_F) {
                        sg_u |= (otx2_nix_prefree_seg(m) << (i + 55));
+                       /* Commit changes to mbuf */
+                       rte_io_wmb();
+               }
                /* Mark mempool object as "put" since it is freed by NIX */
-               if (!(sg_u & (1ULL << (i + 55)))) {
-                       m->next = NULL;
+#ifdef RTE_LIBRTE_MEMPOOL_DEBUG
+               if (!(sg_u & (1ULL << (i + 55))))
                        __mempool_check_cookies(m->pool, (void **)&m, 1, 0);
-               }
+               rte_io_wmb();
+#endif
                slist++;
                i++;
                nb_segs--;
@@ -453,6 +479,12 @@ otx2_nix_prepare_mseg(struct rte_mbuf *m, uint64_t *cmd, const uint16_t flags)
        return segdw;
 }
 
+static __rte_always_inline void
+otx2_nix_xmit_mseg_prep_lmt(uint64_t *cmd, void *lmt_addr, uint16_t segdw)
+{
+       otx2_lmt_mov_seg(lmt_addr, (const void *)cmd, segdw);
+}
+
 static __rte_always_inline void
 otx2_nix_xmit_mseg_one(uint64_t *cmd, void *lmt_addr,
                       rte_iova_t io_addr, uint16_t segdw)
@@ -465,6 +497,19 @@ otx2_nix_xmit_mseg_one(uint64_t *cmd, void *lmt_addr,
        } while (lmt_status == 0);
 }
 
+static __rte_always_inline void
+otx2_nix_xmit_mseg_one_release(uint64_t *cmd, void *lmt_addr,
+                      rte_iova_t io_addr, uint16_t segdw)
+{
+       uint64_t lmt_status;
+
+       rte_io_wmb();
+       do {
+               otx2_lmt_mov_seg(lmt_addr, (const void *)cmd, segdw);
+               lmt_status = otx2_lmt_submit(io_addr);
+       } while (lmt_status == 0);
+}
+
 #define L3L4CSUM_F   NIX_TX_OFFLOAD_L3_L4_CSUM_F
 #define OL3OL4CSUM_F NIX_TX_OFFLOAD_OL3_OL4_CSUM_F
 #define VLAN_F       NIX_TX_OFFLOAD_VLAN_QINQ_F