1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright (c) 2009-2018 Microsoft Corp.
3 * Copyright (c) 2016 Brocade Communications Systems, Inc.
4 * Copyright (c) 2012 NetApp Inc.
5 * Copyright (c) 2012 Citrix Inc.
10 * Tunable ethdev params
12 #define HN_MIN_RX_BUF_SIZE 1024
13 #define HN_MAX_XFER_LEN 2048
14 #define HN_MAX_MAC_ADDRS 1
15 #define HN_MAX_CHANNELS 64
17 /* Claimed to be 12232B */
18 #define HN_MTU_MAX (9 * 1024)
21 #define HN_CHAN_INTERVAL_US 100
23 /* Host monitor interval */
24 #define HN_CHAN_LATENCY_NS 50000
26 /* Buffers need to be aligned */
28 #define PAGE_SIZE 4096
32 #define PAGE_MASK (PAGE_SIZE - 1)
45 /* Size bins in array as RFC 2819, undersized [0], 64 [1], etc */
46 uint64_t size_bins[8];
51 struct vmbus_channel *chan;
56 /* Applied packet transmission aggregation limits. */
61 /* Packet transmission aggregation states */
62 struct hn_txdesc *agg_txd;
65 struct rndis_packet_msg *agg_prevpkt;
67 struct hn_stats stats;
72 struct vmbus_channel *chan;
73 struct rte_mempool *mb_pool;
74 struct rte_ring *rx_ring;
76 rte_spinlock_t ring_lock;
80 struct hn_stats stats;
86 /* multi-packet data from host */
87 struct hn_rx_bufinfo {
88 struct vmbus_channel *chan;
91 struct rte_mbuf_ext_shared_info shinfo;
92 } __rte_cache_aligned;
95 struct rte_vmbus_device *vmbus;
96 struct hn_rx_queue *primary;
97 struct rte_eth_dev *vf_dev; /* Subordinate device */
98 rte_spinlock_t vf_lock;
102 uint32_t link_status;
105 struct rte_mem_resource *rxbuf_res; /* UIO resource for Rx */
106 struct hn_rx_bufinfo *rxbuf_info;
107 uint32_t rxbuf_section_cnt; /* # of Rx sections */
108 volatile uint32_t rxbuf_outstanding;
109 uint16_t max_queues; /* Max available queues */
111 uint64_t rss_offloads;
113 struct rte_mem_resource *chim_res; /* UIO resource for Tx */
114 struct rte_mempool *tx_pool; /* Tx descriptors */
115 uint32_t chim_szmax; /* Max size per buffer */
116 uint32_t chim_cnt; /* Max packets per buffer */
121 uint32_t rndis_agg_size;
122 uint32_t rndis_agg_pkts;
123 uint32_t rndis_agg_align;
125 volatile uint32_t rndis_pending;
126 rte_atomic32_t rndis_req_id;
127 uint8_t rndis_resp[256];
129 struct ether_addr mac_addr;
131 struct rte_eth_dev_owner owner;
132 struct rte_intr_handle vf_intr;
134 struct vmbus_channel *channels[HN_MAX_CHANNELS];
137 static inline struct vmbus_channel *
138 hn_primary_chan(const struct hn_data *hv)
140 return hv->channels[0];
143 uint32_t hn_process_events(struct hn_data *hv, uint16_t queue_id,
146 uint16_t hn_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
148 uint16_t hn_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
151 int hn_tx_pool_init(struct rte_eth_dev *dev);
152 int hn_dev_link_update(struct rte_eth_dev *dev, int wait);
153 int hn_dev_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
154 uint16_t nb_desc, unsigned int socket_id,
155 const struct rte_eth_txconf *tx_conf);
156 void hn_dev_tx_queue_release(void *arg);
157 void hn_dev_tx_queue_info(struct rte_eth_dev *dev, uint16_t queue_idx,
158 struct rte_eth_txq_info *qinfo);
159 int hn_dev_tx_done_cleanup(void *arg, uint32_t free_cnt);
161 struct hn_rx_queue *hn_rx_queue_alloc(struct hn_data *hv,
163 unsigned int socket_id);
164 int hn_dev_rx_queue_setup(struct rte_eth_dev *dev,
165 uint16_t queue_idx, uint16_t nb_desc,
166 unsigned int socket_id,
167 const struct rte_eth_rxconf *rx_conf,
168 struct rte_mempool *mp);
169 void hn_dev_rx_queue_release(void *arg);
171 void hn_vf_info_get(struct hn_data *hv,
172 struct rte_eth_dev_info *info);
173 int hn_vf_add(struct rte_eth_dev *dev, struct hn_data *hv);
174 int hn_vf_configure(struct rte_eth_dev *dev,
175 const struct rte_eth_conf *dev_conf);
176 const uint32_t *hn_vf_supported_ptypes(struct rte_eth_dev *dev);
177 int hn_vf_start(struct rte_eth_dev *dev);
178 void hn_vf_reset(struct rte_eth_dev *dev);
179 void hn_vf_stop(struct rte_eth_dev *dev);
180 void hn_vf_close(struct rte_eth_dev *dev);
181 int hn_vf_link_update(struct rte_eth_dev *dev,
182 int wait_to_complete);
183 int hn_vf_tx_queue_setup(struct rte_eth_dev *dev,
184 uint16_t queue_idx, uint16_t nb_desc,
185 unsigned int socket_id,
186 const struct rte_eth_txconf *tx_conf);
187 void hn_vf_tx_queue_release(struct hn_data *hv, uint16_t queue_id);
188 int hn_vf_rx_queue_setup(struct rte_eth_dev *dev,
189 uint16_t queue_idx, uint16_t nb_desc,
190 unsigned int socket_id,
191 const struct rte_eth_rxconf *rx_conf,
192 struct rte_mempool *mp);
193 void hn_vf_rx_queue_release(struct hn_data *hv, uint16_t queue_id);
195 int hn_vf_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats);
196 void hn_vf_stats_reset(struct rte_eth_dev *dev);
197 int hn_vf_xstats_get_names(struct rte_eth_dev *dev,
198 struct rte_eth_xstat_name *xstats_names,
200 int hn_vf_xstats_get(struct rte_eth_dev *dev,
201 struct rte_eth_xstat *xstats,
203 void hn_vf_xstats_reset(struct rte_eth_dev *dev);