| 2144 | } |
| 2145 | |
| 2146 | int |
| 2147 | rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id, |
| 2148 | uint16_t nb_rx_desc, unsigned int socket_id, |
| 2149 | const struct rte_eth_rxconf *rx_conf, |
| 2150 | struct rte_mempool *mp) |
| 2151 | { |
| 2152 | int ret; |
| 2153 | uint64_t rx_offloads; |
| 2154 | uint32_t mbp_buf_size = UINT32_MAX; |
| 2155 | struct rte_eth_dev *dev; |
| 2156 | struct rte_eth_dev_info dev_info; |
| 2157 | struct rte_eth_rxconf local_conf; |
| 2158 | uint32_t buf_data_size; |
| 2159 | |
| 2160 | RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); |
| 2161 | dev = &rte_eth_devices[port_id]; |
| 2162 | |
| 2163 | if (rx_queue_id >= dev->data->nb_rx_queues) { |
| 2164 | RTE_ETHDEV_LOG(ERR, "Invalid Rx queue_id=%u\n", rx_queue_id); |
| 2165 | return -EINVAL; |
| 2166 | } |
| 2167 | |
| 2168 | if (*dev->dev_ops->rx_queue_setup == NULL) |
| 2169 | return -ENOTSUP; |
| 2170 | |
| 2171 | if (rx_conf != NULL && |
| 2172 | (rx_conf->reserved_64s[0] != 0 || |
| 2173 | rx_conf->reserved_64s[1] != 0 || |
| 2174 | rx_conf->reserved_ptrs[0] != NULL || |
| 2175 | rx_conf->reserved_ptrs[1] != NULL)) { |
| 2176 | RTE_ETHDEV_LOG(ERR, "Rx conf reserved fields not zero\n"); |
| 2177 | return -EINVAL; |
| 2178 | } |
| 2179 | |
| 2180 | ret = rte_eth_dev_info_get(port_id, &dev_info); |
| 2181 | if (ret != 0) |
| 2182 | return ret; |
| 2183 | |
| 2184 | rx_offloads = dev->data->dev_conf.rxmode.offloads; |
| 2185 | if (rx_conf != NULL) |
| 2186 | rx_offloads |= rx_conf->offloads; |
| 2187 | |
| 2188 | /* Ensure that we have one and only one source of Rx buffers */ |
| 2189 | if ((mp != NULL) + |
| 2190 | (rx_conf != NULL && rx_conf->rx_nseg > 0) + |
| 2191 | (rx_conf != NULL && rx_conf->rx_nmempool > 0) != 1) { |
| 2192 | RTE_ETHDEV_LOG(ERR, |
| 2193 | "Ambiguous Rx mempools configuration\n"); |
| 2194 | return -EINVAL; |
| 2195 | } |
| 2196 | |
| 2197 | if (mp != NULL) { |
| 2198 | /* Single pool configuration check. */ |
| 2199 | ret = rte_eth_check_rx_mempool(mp, RTE_PKTMBUF_HEADROOM, |
| 2200 | dev_info.min_rx_bufsize); |
| 2201 | if (ret != 0) |
| 2202 | return ret; |
| 2203 | |