| 1477 | } |
| 1478 | |
| 1479 | static int |
| 1480 | tap_setup_queue(struct rte_eth_dev *dev, |
| 1481 | struct pmd_internals *internals, |
| 1482 | uint16_t qid, |
| 1483 | int is_rx) |
| 1484 | { |
| 1485 | int ret; |
| 1486 | int *fd; |
| 1487 | int *other_fd; |
| 1488 | const char *dir; |
| 1489 | struct pmd_internals *pmd = dev->data->dev_private; |
| 1490 | struct pmd_process_private *process_private = dev->process_private; |
| 1491 | struct rx_queue *rx = &internals->rxq[qid]; |
| 1492 | struct tx_queue *tx = &internals->txq[qid]; |
| 1493 | struct rte_gso_ctx *gso_ctx; |
| 1494 | |
| 1495 | if (is_rx) { |
| 1496 | fd = &process_private->rxq_fds[qid]; |
| 1497 | other_fd = &process_private->txq_fds[qid]; |
| 1498 | dir = "rx"; |
| 1499 | gso_ctx = NULL; |
| 1500 | } else { |
| 1501 | fd = &process_private->txq_fds[qid]; |
| 1502 | other_fd = &process_private->rxq_fds[qid]; |
| 1503 | dir = "tx"; |
| 1504 | gso_ctx = &tx->gso_ctx; |
| 1505 | } |
| 1506 | if (*fd != -1) { |
| 1507 | /* fd for this queue already exists */ |
| 1508 | TAP_LOG(DEBUG, "%s: fd %d for %s queue qid %d exists", |
| 1509 | pmd->name, *fd, dir, qid); |
| 1510 | gso_ctx = NULL; |
| 1511 | } else if (*other_fd != -1) { |
| 1512 | /* Only other_fd exists. dup it */ |
| 1513 | *fd = dup(*other_fd); |
| 1514 | if (*fd < 0) { |
| 1515 | *fd = -1; |
| 1516 | TAP_LOG(ERR, "%s: dup() failed.", pmd->name); |
| 1517 | return -1; |
| 1518 | } |
| 1519 | TAP_LOG(DEBUG, "%s: dup fd %d for %s queue qid %d (%d)", |
| 1520 | pmd->name, *other_fd, dir, qid, *fd); |
| 1521 | } else { |
| 1522 | /* Both RX and TX fds do not exist (equal -1). Create fd */ |
| 1523 | *fd = tun_alloc(pmd, 0, 0); |
| 1524 | if (*fd < 0) { |
| 1525 | *fd = -1; /* restore original value */ |
| 1526 | TAP_LOG(ERR, "%s: tun_alloc() failed.", pmd->name); |
| 1527 | return -1; |
| 1528 | } |
| 1529 | TAP_LOG(DEBUG, "%s: add %s queue for qid %d fd %d", |
| 1530 | pmd->name, dir, qid, *fd); |
| 1531 | } |
| 1532 | |
| 1533 | tx->mtu = &dev->data->mtu; |
| 1534 | rx->rxmode = &dev->data->dev_conf.rxmode; |
| 1535 | if (gso_ctx) { |
| 1536 | ret = tap_gso_ctx_setup(gso_ctx, dev); |
no test coverage detected