| 1926 | } |
| 1927 | |
| 1928 | int |
| 1929 | ngbe_dev_tx_queue_setup(struct rte_eth_dev *dev, |
| 1930 | uint16_t queue_idx, |
| 1931 | uint16_t nb_desc, |
| 1932 | unsigned int socket_id, |
| 1933 | const struct rte_eth_txconf *tx_conf) |
| 1934 | { |
| 1935 | const struct rte_memzone *tz; |
| 1936 | struct ngbe_tx_queue *txq; |
| 1937 | struct ngbe_hw *hw; |
| 1938 | uint16_t tx_free_thresh; |
| 1939 | uint64_t offloads; |
| 1940 | |
| 1941 | PMD_INIT_FUNC_TRACE(); |
| 1942 | hw = ngbe_dev_hw(dev); |
| 1943 | |
| 1944 | offloads = tx_conf->offloads | dev->data->dev_conf.txmode.offloads; |
| 1945 | |
| 1946 | /* |
| 1947 | * The Tx descriptor ring will be cleaned after txq->tx_free_thresh |
| 1948 | * descriptors are used or if the number of descriptors required |
| 1949 | * to transmit a packet is greater than the number of free Tx |
| 1950 | * descriptors. |
| 1951 | * One descriptor in the Tx ring is used as a sentinel to avoid a |
| 1952 | * H/W race condition, hence the maximum threshold constraints. |
| 1953 | * When set to zero use default values. |
| 1954 | */ |
| 1955 | tx_free_thresh = (uint16_t)((tx_conf->tx_free_thresh) ? |
| 1956 | tx_conf->tx_free_thresh : DEFAULT_TX_FREE_THRESH); |
| 1957 | if (tx_free_thresh >= (nb_desc - 3)) { |
| 1958 | PMD_INIT_LOG(ERR, |
| 1959 | "tx_free_thresh must be less than the number of TX descriptors minus 3. (tx_free_thresh=%u port=%d queue=%d)", |
| 1960 | (unsigned int)tx_free_thresh, |
| 1961 | (int)dev->data->port_id, (int)queue_idx); |
| 1962 | return -(EINVAL); |
| 1963 | } |
| 1964 | |
| 1965 | if (nb_desc % tx_free_thresh != 0) { |
| 1966 | PMD_INIT_LOG(ERR, |
| 1967 | "tx_free_thresh must be a divisor of the number of Tx descriptors. (tx_free_thresh=%u port=%d queue=%d)", |
| 1968 | (unsigned int)tx_free_thresh, |
| 1969 | (int)dev->data->port_id, (int)queue_idx); |
| 1970 | return -(EINVAL); |
| 1971 | } |
| 1972 | |
| 1973 | /* Free memory prior to re-allocation if needed... */ |
| 1974 | if (dev->data->tx_queues[queue_idx] != NULL) { |
| 1975 | ngbe_tx_queue_release(dev->data->tx_queues[queue_idx]); |
| 1976 | dev->data->tx_queues[queue_idx] = NULL; |
| 1977 | } |
| 1978 | |
| 1979 | /* First allocate the Tx queue data structure */ |
| 1980 | txq = rte_zmalloc_socket("ethdev Tx queue", |
| 1981 | sizeof(struct ngbe_tx_queue), |
| 1982 | RTE_CACHE_LINE_SIZE, socket_id); |
| 1983 | if (txq == NULL) |
| 1984 | return -ENOMEM; |
| 1985 |
nothing calls this directly
no test coverage detected