* alloc_ring - allocate resources for an SGE descriptor ring * @dev: the port associated with the queue * @z_name: memzone's name * @queue_id: queue index * @socket_id: preferred socket id for memory allocations * @nelem: the number of descriptors * @elem_size: the size of each descriptor * @stat_size: extra space in HW ring for status information * @sw_size: the size of the SW state assoc
| 1383 | * of the SW ring. |
| 1384 | */ |
| 1385 | static void *alloc_ring(struct rte_eth_dev *dev, const char *z_name, |
| 1386 | uint16_t queue_id, int socket_id, size_t nelem, |
| 1387 | size_t elem_size, size_t stat_size, size_t sw_size, |
| 1388 | dma_addr_t *phys, void *metadata) |
| 1389 | { |
| 1390 | size_t len = CXGBE_MAX_RING_DESC_SIZE * elem_size + stat_size; |
| 1391 | char z_name_sw[RTE_MEMZONE_NAMESIZE]; |
| 1392 | const struct rte_memzone *tz; |
| 1393 | void *s = NULL; |
| 1394 | |
| 1395 | snprintf(z_name_sw, sizeof(z_name_sw), "eth_p%d_q%d_%s_sw_ring", |
| 1396 | dev->data->port_id, queue_id, z_name); |
| 1397 | |
| 1398 | dev_debug(adapter, "%s: nelem = %zu; elem_size = %zu; sw_size = %zu; " |
| 1399 | "stat_size = %zu; queue_id = %u; socket_id = %d; z_name = %s;" |
| 1400 | " z_name_sw = %s\n", __func__, nelem, elem_size, sw_size, |
| 1401 | stat_size, queue_id, socket_id, z_name, z_name_sw); |
| 1402 | |
| 1403 | /* |
| 1404 | * Allocate TX/RX ring hardware descriptors. A memzone large enough to |
| 1405 | * handle the maximum ring size is allocated in order to allow for |
| 1406 | * resizing in later calls to the queue setup function. |
| 1407 | */ |
| 1408 | tz = rte_eth_dma_zone_reserve(dev, z_name, queue_id, len, 4096, |
| 1409 | socket_id); |
| 1410 | if (!tz) |
| 1411 | return NULL; |
| 1412 | |
| 1413 | memset(tz->addr, 0, len); |
| 1414 | if (sw_size) { |
| 1415 | s = rte_zmalloc_socket(z_name_sw, nelem * sw_size, |
| 1416 | RTE_CACHE_LINE_SIZE, socket_id); |
| 1417 | |
| 1418 | if (!s) { |
| 1419 | dev_err(adapter, "%s: failed to get sw_ring memory\n", |
| 1420 | __func__); |
| 1421 | return NULL; |
| 1422 | } |
| 1423 | } |
| 1424 | if (metadata) |
| 1425 | *(void **)metadata = s; |
| 1426 | |
| 1427 | *phys = (uint64_t)tz->iova; |
| 1428 | return tz->addr; |
| 1429 | } |
| 1430 | |
| 1431 | #define CXGB4_MSG_AN ((void *)1) |
| 1432 |
no test coverage detected