]> git.proxmox.com Git - ceph.git/blob - ceph/src/dpdk/drivers/net/thunderx/nicvf_rxtx.h
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / dpdk / drivers / net / thunderx / nicvf_rxtx.h
1 /*
2 * BSD LICENSE
3 *
4 * Copyright (C) Cavium networks Ltd. 2016.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 *
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
15 * distribution.
16 * * Neither the name of Cavium networks 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.
19 *
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.
31 */
32
33 #ifndef __THUNDERX_NICVF_RXTX_H__
34 #define __THUNDERX_NICVF_RXTX_H__
35
36 #include <rte_byteorder.h>
37 #include <rte_ethdev.h>
38
39 #define NICVF_TX_OFFLOAD_MASK (PKT_TX_IP_CKSUM | PKT_TX_L4_MASK)
40
41 #ifndef __hot
42 #define __hot __attribute__((hot))
43 #endif
44
45 #if RTE_BYTE_ORDER == RTE_BIG_ENDIAN
46 static inline uint16_t __attribute__((const))
47 nicvf_frag_num(uint16_t i)
48 {
49 return (i & ~3) + 3 - (i & 3);
50 }
51
52 static inline void __hot
53 fill_sq_desc_gather(union sq_entry_t *entry, struct rte_mbuf *pkt)
54 {
55 /* Local variable sqe to avoid read from sq desc memory*/
56 union sq_entry_t sqe;
57
58 /* Fill the SQ gather entry */
59 sqe.buff[0] = 0; sqe.buff[1] = 0;
60 sqe.gather.subdesc_type = SQ_DESC_TYPE_GATHER;
61 sqe.gather.ld_type = NIC_SEND_LD_TYPE_E_LDT;
62 sqe.gather.size = pkt->data_len;
63 sqe.gather.addr = rte_mbuf_data_dma_addr(pkt);
64
65 entry->buff[0] = sqe.buff[0];
66 entry->buff[1] = sqe.buff[1];
67 }
68
69 #else
70
71 static inline uint16_t __attribute__((const))
72 nicvf_frag_num(uint16_t i)
73 {
74 return i;
75 }
76
77 static inline void __hot
78 fill_sq_desc_gather(union sq_entry_t *entry, struct rte_mbuf *pkt)
79 {
80 entry->buff[0] = (uint64_t)SQ_DESC_TYPE_GATHER << 60 |
81 (uint64_t)NIC_SEND_LD_TYPE_E_LDT << 58 |
82 pkt->data_len;
83 entry->buff[1] = rte_mbuf_data_dma_addr(pkt);
84 }
85 #endif
86
87 uint32_t nicvf_dev_rx_queue_count(struct rte_eth_dev *dev, uint16_t queue_idx);
88 uint32_t nicvf_dev_rbdr_refill(struct rte_eth_dev *dev, uint16_t queue_idx);
89
90 uint16_t nicvf_recv_pkts(void *rxq, struct rte_mbuf **rx_pkts, uint16_t pkts);
91 uint16_t nicvf_recv_pkts_multiseg(void *rx_queue, struct rte_mbuf **rx_pkts,
92 uint16_t nb_pkts);
93
94 uint16_t nicvf_xmit_pkts(void *txq, struct rte_mbuf **tx_pkts, uint16_t pkts);
95 uint16_t nicvf_xmit_pkts_multiseg(void *txq, struct rte_mbuf **tx_pkts,
96 uint16_t pkts);
97
98 void nicvf_single_pool_free_xmited_buffers(struct nicvf_txq *sq);
99 void nicvf_multi_pool_free_xmited_buffers(struct nicvf_txq *sq);
100
101 #endif /* __THUNDERX_NICVF_RXTX_H__ */