MCPcopy Create free account
hub / github.com/F-Stack/f-stack / txgbe_dev_tx_queue_setup

Function txgbe_dev_tx_queue_setup

dpdk/drivers/net/txgbe/txgbe_rxtx.c:2268–2404  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2266}
2267
2268int __rte_cold
2269txgbe_dev_tx_queue_setup(struct rte_eth_dev *dev,
2270 uint16_t queue_idx,
2271 uint16_t nb_desc,
2272 unsigned int socket_id,
2273 const struct rte_eth_txconf *tx_conf)
2274{
2275 const struct rte_memzone *tz;
2276 struct txgbe_tx_queue *txq;
2277 struct txgbe_hw *hw;
2278 uint16_t tx_free_thresh;
2279 uint64_t offloads;
2280
2281 PMD_INIT_FUNC_TRACE();
2282 hw = TXGBE_DEV_HW(dev);
2283
2284 offloads = tx_conf->offloads | dev->data->dev_conf.txmode.offloads;
2285
2286 /*
2287 * Validate number of transmit descriptors.
2288 * It must not exceed hardware maximum, and must be multiple
2289 * of TXGBE_ALIGN.
2290 */
2291 if (nb_desc % TXGBE_TXD_ALIGN != 0 ||
2292 nb_desc > TXGBE_RING_DESC_MAX ||
2293 nb_desc < TXGBE_RING_DESC_MIN) {
2294 return -EINVAL;
2295 }
2296
2297 /*
2298 * The TX descriptor ring will be cleaned after txq->tx_free_thresh
2299 * descriptors are used or if the number of descriptors required
2300 * to transmit a packet is greater than the number of free TX
2301 * descriptors.
2302 * One descriptor in the TX ring is used as a sentinel to avoid a
2303 * H/W race condition, hence the maximum threshold constraints.
2304 * When set to zero use default values.
2305 */
2306 tx_free_thresh = (uint16_t)((tx_conf->tx_free_thresh) ?
2307 tx_conf->tx_free_thresh : DEFAULT_TX_FREE_THRESH);
2308 if (tx_free_thresh >= (nb_desc - 3)) {
2309 PMD_INIT_LOG(ERR, "tx_free_thresh must be less than the number of "
2310 "TX descriptors minus 3. (tx_free_thresh=%u "
2311 "port=%d queue=%d)",
2312 (unsigned int)tx_free_thresh,
2313 (int)dev->data->port_id, (int)queue_idx);
2314 return -(EINVAL);
2315 }
2316
2317 if ((nb_desc % tx_free_thresh) != 0) {
2318 PMD_INIT_LOG(ERR, "tx_free_thresh must be a divisor of the "
2319 "number of TX descriptors. (tx_free_thresh=%u "
2320 "port=%d queue=%d)", (unsigned int)tx_free_thresh,
2321 (int)dev->data->port_id, (int)queue_idx);
2322 return -(EINVAL);
2323 }
2324
2325 /* Free memory prior to re-allocation if needed... */

Callers

nothing calls this directly

Calls 4

txgbe_tx_queue_releaseFunction · 0.85
rte_zmalloc_socketFunction · 0.85
rte_eth_dma_zone_reserveFunction · 0.85
resetMethod · 0.45

Tested by

no test coverage detected