net/ark: update DDM functions for firmware update
[dpdk.git] / drivers / net / virtio / virtio_ethdev.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2010-2015 Intel Corporation
3  */
4
5 #ifndef _VIRTIO_ETHDEV_H_
6 #define _VIRTIO_ETHDEV_H_
7
8 #include <stdint.h>
9
10 #include <ethdev_driver.h>
11
12 #include "virtio.h"
13
14 #define VIRTIO_MAX_RX_QUEUES 128U
15 #define VIRTIO_MAX_TX_QUEUES 128U
16 #define VIRTIO_MAX_MAC_ADDRS 64
17 #define VIRTIO_MIN_RX_BUFSIZE 64
18 #define VIRTIO_MAX_RX_PKTLEN  9728U
19
20 /* Features desired/implemented by this driver. */
21 #define VIRTIO_PMD_DEFAULT_GUEST_FEATURES       \
22         (1u << VIRTIO_NET_F_MAC           |     \
23          1u << VIRTIO_NET_F_STATUS        |     \
24          1u << VIRTIO_NET_F_MQ            |     \
25          1u << VIRTIO_NET_F_CTRL_MAC_ADDR |     \
26          1u << VIRTIO_NET_F_CTRL_VQ       |     \
27          1u << VIRTIO_NET_F_CTRL_RX       |     \
28          1u << VIRTIO_NET_F_CTRL_VLAN     |     \
29          1u << VIRTIO_NET_F_MRG_RXBUF     |     \
30          1u << VIRTIO_NET_F_MTU | \
31          1ULL << VIRTIO_NET_F_GUEST_ANNOUNCE |  \
32          1u << VIRTIO_RING_F_INDIRECT_DESC |    \
33          1ULL << VIRTIO_F_VERSION_1       |     \
34          1ULL << VIRTIO_F_IN_ORDER        |     \
35          1ULL << VIRTIO_F_RING_PACKED     |     \
36          1ULL << VIRTIO_F_IOMMU_PLATFORM  |     \
37          1ULL << VIRTIO_F_ORDER_PLATFORM  |     \
38          1ULL << VIRTIO_F_NOTIFICATION_DATA | \
39          1ULL << VIRTIO_NET_F_SPEED_DUPLEX)
40
41 #define VIRTIO_PMD_SUPPORTED_GUEST_FEATURES     \
42         (VIRTIO_PMD_DEFAULT_GUEST_FEATURES |    \
43          1u << VIRTIO_NET_F_GUEST_CSUM     |    \
44          1u << VIRTIO_NET_F_GUEST_TSO4     |    \
45          1u << VIRTIO_NET_F_GUEST_TSO6     |    \
46          1u << VIRTIO_NET_F_CSUM           |    \
47          1u << VIRTIO_NET_F_HOST_TSO4      |    \
48          1u << VIRTIO_NET_F_HOST_TSO6      |    \
49          1ULL << VIRTIO_NET_F_RSS)
50
51 extern const struct eth_dev_ops virtio_user_secondary_eth_dev_ops;
52
53 /*
54  * CQ function prototype
55  */
56 void virtio_dev_cq_start(struct rte_eth_dev *dev);
57
58 /*
59  * RX/TX function prototypes
60  */
61
62 int  virtio_dev_rx_queue_setup(struct rte_eth_dev *dev, uint16_t rx_queue_id,
63                 uint16_t nb_rx_desc, unsigned int socket_id,
64                 const struct rte_eth_rxconf *rx_conf,
65                 struct rte_mempool *mb_pool);
66
67 int virtio_dev_rx_queue_setup_finish(struct rte_eth_dev *dev,
68                                 uint16_t rx_queue_id);
69
70 int  virtio_dev_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id,
71                 uint16_t nb_tx_desc, unsigned int socket_id,
72                 const struct rte_eth_txconf *tx_conf);
73
74 int virtio_dev_tx_queue_setup_finish(struct rte_eth_dev *dev,
75                                 uint16_t tx_queue_id);
76
77 uint16_t virtio_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
78                 uint16_t nb_pkts);
79 uint16_t virtio_recv_pkts_packed(void *rx_queue, struct rte_mbuf **rx_pkts,
80                 uint16_t nb_pkts);
81
82 uint16_t virtio_recv_mergeable_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
83                 uint16_t nb_pkts);
84
85 uint16_t virtio_recv_mergeable_pkts_packed(void *rx_queue,
86                 struct rte_mbuf **rx_pkts, uint16_t nb_pkts);
87
88 uint16_t virtio_recv_pkts_inorder(void *rx_queue,
89                 struct rte_mbuf **rx_pkts, uint16_t nb_pkts);
90
91 uint16_t virtio_xmit_pkts_prepare(void *tx_queue, struct rte_mbuf **tx_pkts,
92                 uint16_t nb_pkts);
93
94 uint16_t virtio_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
95                 uint16_t nb_pkts);
96 uint16_t virtio_xmit_pkts_packed(void *tx_queue, struct rte_mbuf **tx_pkts,
97                 uint16_t nb_pkts);
98
99 uint16_t virtio_xmit_pkts_inorder(void *tx_queue, struct rte_mbuf **tx_pkts,
100                 uint16_t nb_pkts);
101
102 uint16_t virtio_recv_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
103                 uint16_t nb_pkts);
104
105 uint16_t virtio_recv_pkts_packed_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
106                 uint16_t nb_pkts);
107
108 uint16_t virtio_xmit_pkts_packed_vec(void *tx_queue, struct rte_mbuf **tx_pkts,
109                 uint16_t nb_pkts);
110
111 int eth_virtio_dev_init(struct rte_eth_dev *eth_dev);
112
113 void virtio_interrupt_handler(void *param);
114
115 int virtio_dev_pause(struct rte_eth_dev *dev);
116 void virtio_dev_resume(struct rte_eth_dev *dev);
117 int virtio_dev_stop(struct rte_eth_dev *dev);
118 int virtio_dev_close(struct rte_eth_dev *dev);
119 int virtio_inject_pkts(struct rte_eth_dev *dev, struct rte_mbuf **tx_pkts,
120                 int nb_pkts);
121
122 bool virtio_rx_check_scatter(uint16_t max_rx_pkt_len, uint16_t rx_buf_size,
123                         bool rx_scatter_enabled, const char **error);
124
125 uint16_t virtio_rx_mem_pool_buf_size(struct rte_mempool *mp);
126
127 #endif /* _VIRTIO_ETHDEV_H_ */