1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2014-2020 Broadcom
9 #include "hsi_struct_def_dpdk.h"
11 static const struct eth_dev_ops bnxt_vf_rep_dev_ops = {
12 .dev_infos_get = bnxt_vf_rep_dev_info_get_op,
13 .dev_configure = bnxt_vf_rep_dev_configure_op,
14 .dev_start = bnxt_vf_rep_dev_start_op,
15 .rx_queue_setup = bnxt_vf_rep_rx_queue_setup_op,
16 .tx_queue_setup = bnxt_vf_rep_tx_queue_setup_op,
17 .link_update = bnxt_vf_rep_link_update_op,
18 .dev_close = bnxt_vf_rep_dev_close_op,
19 .dev_stop = bnxt_vf_rep_dev_stop_op
23 bnxt_vf_rep_rx_burst(__rte_unused void *rx_queue,
24 __rte_unused struct rte_mbuf **rx_pkts,
25 __rte_unused uint16_t nb_pkts)
31 bnxt_vf_rep_tx_burst(__rte_unused void *tx_queue,
32 __rte_unused struct rte_mbuf **tx_pkts,
33 __rte_unused uint16_t nb_pkts)
38 int bnxt_vf_representor_init(struct rte_eth_dev *eth_dev, void *params)
40 struct bnxt_vf_representor *vf_rep_bp = eth_dev->data->dev_private;
41 struct bnxt_vf_representor *rep_params =
42 (struct bnxt_vf_representor *)params;
43 struct rte_eth_link *link;
44 struct bnxt *parent_bp;
46 vf_rep_bp->vf_id = rep_params->vf_id;
47 vf_rep_bp->switch_domain_id = rep_params->switch_domain_id;
48 vf_rep_bp->parent_priv = rep_params->parent_priv;
50 eth_dev->data->dev_flags |= RTE_ETH_DEV_REPRESENTOR;
51 eth_dev->data->representor_id = rep_params->vf_id;
53 rte_eth_random_addr(vf_rep_bp->dflt_mac_addr);
54 memcpy(vf_rep_bp->mac_addr, vf_rep_bp->dflt_mac_addr,
55 sizeof(vf_rep_bp->mac_addr));
56 eth_dev->data->mac_addrs =
57 (struct rte_ether_addr *)&vf_rep_bp->mac_addr;
58 eth_dev->dev_ops = &bnxt_vf_rep_dev_ops;
60 /* No data-path, but need stub Rx/Tx functions to avoid crash
61 * when testing with ovs-dpdk
63 eth_dev->rx_pkt_burst = bnxt_vf_rep_rx_burst;
64 eth_dev->tx_pkt_burst = bnxt_vf_rep_tx_burst;
65 /* Link state. Inherited from PF or trusted VF */
66 parent_bp = vf_rep_bp->parent_priv;
67 link = &parent_bp->eth_dev->data->dev_link;
69 eth_dev->data->dev_link.link_speed = link->link_speed;
70 eth_dev->data->dev_link.link_duplex = link->link_duplex;
71 eth_dev->data->dev_link.link_status = link->link_status;
72 eth_dev->data->dev_link.link_autoneg = link->link_autoneg;
74 PMD_DRV_LOG(INFO, "calling bnxt_print_link_info\n");
75 bnxt_print_link_info(eth_dev);
77 /* Pass the information to the rte_eth_dev_close() that it should also
78 * release the private port resources.
80 eth_dev->data->dev_flags |= RTE_ETH_DEV_CLOSE_REMOVE;
82 "Switch domain id %d: Representor Device %d init done\n",
83 vf_rep_bp->switch_domain_id, vf_rep_bp->vf_id);
88 int bnxt_vf_representor_uninit(struct rte_eth_dev *eth_dev)
90 struct bnxt *parent_bp;
91 struct bnxt_vf_representor *rep =
92 (struct bnxt_vf_representor *)eth_dev->data->dev_private;
96 eth_dev->data->mac_addrs = NULL;
98 parent_bp = rep->parent_priv;
100 parent_bp->num_reps--;
102 memset(&parent_bp->rep_info[vf_id], 0,
103 sizeof(parent_bp->rep_info[vf_id]));
104 /* mark that this representor has been freed */
106 eth_dev->dev_ops = NULL;
110 int bnxt_vf_rep_link_update_op(struct rte_eth_dev *eth_dev, int wait_to_compl)
112 struct bnxt *parent_bp;
113 struct bnxt_vf_representor *rep =
114 (struct bnxt_vf_representor *)eth_dev->data->dev_private;
115 struct rte_eth_link *link;
118 parent_bp = rep->parent_priv;
119 rc = bnxt_link_update_op(parent_bp->eth_dev, wait_to_compl);
121 /* Link state. Inherited from PF or trusted VF */
122 link = &parent_bp->eth_dev->data->dev_link;
124 eth_dev->data->dev_link.link_speed = link->link_speed;
125 eth_dev->data->dev_link.link_duplex = link->link_duplex;
126 eth_dev->data->dev_link.link_status = link->link_status;
127 eth_dev->data->dev_link.link_autoneg = link->link_autoneg;
128 bnxt_print_link_info(eth_dev);
133 int bnxt_vf_rep_dev_start_op(struct rte_eth_dev *eth_dev)
135 bnxt_vf_rep_link_update_op(eth_dev, 1);
140 void bnxt_vf_rep_dev_stop_op(__rte_unused struct rte_eth_dev *eth_dev)
144 void bnxt_vf_rep_dev_close_op(struct rte_eth_dev *eth_dev)
146 bnxt_vf_representor_uninit(eth_dev);
149 int bnxt_vf_rep_dev_info_get_op(struct rte_eth_dev *eth_dev,
150 struct rte_eth_dev_info *dev_info)
152 struct bnxt_vf_representor *rep_bp = eth_dev->data->dev_private;
153 struct bnxt *parent_bp;
154 uint16_t max_vnics, i, j, vpool, vrxq;
155 unsigned int max_rx_rings;
159 parent_bp = rep_bp->parent_priv;
161 PMD_DRV_LOG(ERR, "Rep parent NULL!\n");
164 PMD_DRV_LOG(DEBUG, "Representor dev_info_get_op\n");
165 dev_info->max_mac_addrs = parent_bp->max_l2_ctx;
166 dev_info->max_hash_mac_addrs = 0;
168 max_rx_rings = BNXT_MAX_VF_REP_RINGS;
169 /* For the sake of symmetry, max_rx_queues = max_tx_queues */
170 dev_info->max_rx_queues = max_rx_rings;
171 dev_info->max_tx_queues = max_rx_rings;
172 dev_info->reta_size = bnxt_rss_hash_tbl_size(parent_bp);
173 dev_info->hash_key_size = 40;
174 max_vnics = parent_bp->max_vnics;
177 dev_info->min_mtu = RTE_ETHER_MIN_MTU;
178 dev_info->max_mtu = BNXT_MAX_MTU;
180 /* Fast path specifics */
181 dev_info->min_rx_bufsize = 1;
182 dev_info->max_rx_pktlen = BNXT_MAX_PKT_LEN;
184 dev_info->rx_offload_capa = BNXT_DEV_RX_OFFLOAD_SUPPORT;
185 if (parent_bp->flags & BNXT_FLAG_PTP_SUPPORTED)
186 dev_info->rx_offload_capa |= DEV_RX_OFFLOAD_TIMESTAMP;
187 dev_info->tx_offload_capa = BNXT_DEV_TX_OFFLOAD_SUPPORT;
188 dev_info->flow_type_rss_offloads = BNXT_ETH_RSS_SUPPORT;
191 dev_info->default_rxconf = (struct rte_eth_rxconf) {
197 .rx_free_thresh = 32,
198 /* If no descriptors available, pkts are dropped by default */
202 dev_info->default_txconf = (struct rte_eth_txconf) {
208 .tx_free_thresh = 32,
211 eth_dev->data->dev_conf.intr_conf.lsc = 1;
213 eth_dev->data->dev_conf.intr_conf.rxq = 1;
214 dev_info->rx_desc_lim.nb_min = BNXT_MIN_RING_DESC;
215 dev_info->rx_desc_lim.nb_max = BNXT_MAX_RX_RING_DESC;
216 dev_info->tx_desc_lim.nb_min = BNXT_MIN_RING_DESC;
217 dev_info->tx_desc_lim.nb_max = BNXT_MAX_TX_RING_DESC;
222 * TODO: default_rxconf, default_txconf, rx_desc_lim, and tx_desc_lim
223 * need further investigation.
227 vpool = 64; /* ETH_64_POOLS */
228 vrxq = 128; /* ETH_VMDQ_DCB_NUM_QUEUES */
229 for (i = 0; i < 4; vpool >>= 1, i++) {
230 if (max_vnics > vpool) {
231 for (j = 0; j < 5; vrxq >>= 1, j++) {
232 if (dev_info->max_rx_queues > vrxq) {
238 /* Not enough resources to support VMDq */
242 /* Not enough resources to support VMDq */
246 dev_info->max_vmdq_pools = vpool;
247 dev_info->vmdq_queue_num = vrxq;
249 dev_info->vmdq_pool_base = 0;
250 dev_info->vmdq_queue_base = 0;
255 int bnxt_vf_rep_dev_configure_op(__rte_unused struct rte_eth_dev *eth_dev)
257 PMD_DRV_LOG(DEBUG, "Representor dev_configure_op\n");
261 int bnxt_vf_rep_rx_queue_setup_op(__rte_unused struct rte_eth_dev *eth_dev,
262 __rte_unused uint16_t queue_idx,
263 __rte_unused uint16_t nb_desc,
264 __rte_unused unsigned int socket_id,
265 __rte_unused const struct rte_eth_rxconf *
267 __rte_unused struct rte_mempool *mp)
272 int bnxt_vf_rep_tx_queue_setup_op(__rte_unused struct rte_eth_dev *eth_dev,
273 __rte_unused uint16_t queue_idx,
274 __rte_unused uint16_t nb_desc,
275 __rte_unused unsigned int socket_id,
276 __rte_unused const struct rte_eth_txconf *