4 * Copyright (C) Cavium, Inc. 2017. All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
16 * * Neither the name of Cavium, Inc nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 #include <rte_atomic.h>
39 #include <rte_common.h>
40 #include <rte_ethdev.h>
41 #include <rte_ether.h>
44 #include <rte_prefetch.h>
46 #include "octeontx_ethdev.h"
47 #include "octeontx_rxtx.h"
48 #include "octeontx_logs.h"
51 static __rte_always_inline uint16_t __hot
52 __octeontx_xmit_pkts(void *lmtline_va, void *ioreg_va, int64_t *fc_status_va,
53 struct rte_mbuf *tx_pkt)
58 if (unlikely(*((volatile int64_t *)fc_status_va) < 0))
61 /* Get the gaura Id */
62 gaura_id = octeontx_fpa_bufpool_gpool((uintptr_t)tx_pkt->pool->pool_id);
64 /* Setup PKO_SEND_HDR_S */
65 cmd_buf[0] = tx_pkt->data_len & 0xffff;
68 /* Set don't free bit if reference count > 1 */
69 if (rte_mbuf_refcnt_read(tx_pkt) > 1)
70 cmd_buf[0] |= (1ULL << 58); /* SET DF */
72 /* Setup PKO_SEND_GATHER_S */
73 cmd_buf[(1 << 1) | 1] = rte_mbuf_data_iova(tx_pkt);
74 cmd_buf[(1 << 1) | 0] = PKO_SEND_GATHER_SUBDC |
75 PKO_SEND_GATHER_LDTYPE(0x1ull) |
76 PKO_SEND_GATHER_GAUAR((long)gaura_id) |
79 octeontx_reg_lmtst(lmtline_va, ioreg_va, cmd_buf, PKO_CMD_SZ);
85 octeontx_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
88 struct octeontx_txq *txq = tx_queue;
89 octeontx_dq_t *dq = &txq->dq;
94 while (count < nb_pkts) {
95 res = __octeontx_xmit_pkts(dq->lmtline_va, dq->ioreg_va,
104 return count; /* return number of pkts transmitted */
108 octeontx_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
110 struct octeontx_rxq *rxq;
113 uint16_t valid_event;
117 while (count < nb_pkts) {
118 valid_event = rte_event_dequeue_burst(rxq->evdev,
123 rx_pkts[count++] = ev.mbuf;
126 return count; /* return number of pkts received */