X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=drivers%2Fnet%2Faf_xdp%2Frte_eth_af_xdp.c;h=b362ccdcd38c1bfe0ac1a1ebb6c27c39681f08dd;hb=63abf8d292252193db075e3264cceb3f6817ed79;hp=c2db21f9c1d80374dbf191af447f6ee2d5f1296a;hpb=eeded2044af5bbe88220120b14933536cbb3edb6;p=dpdk.git diff --git a/drivers/net/af_xdp/rte_eth_af_xdp.c b/drivers/net/af_xdp/rte_eth_af_xdp.c index c2db21f9c1..b362ccdcd3 100644 --- a/drivers/net/af_xdp/rte_eth_af_xdp.c +++ b/drivers/net/af_xdp/rte_eth_af_xdp.c @@ -37,6 +37,7 @@ #include #include #include +#include #include "compat.h" @@ -272,8 +273,18 @@ af_xdp_rx_zc(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) nb_pkts = xsk_ring_cons__peek(rx, nb_pkts, &idx_rx); if (nb_pkts == 0) { - rx_syscall_handler(&rxq->fq, rxq->busy_budget, &rxq->fds[0], - rxq->xsk); + /* we can assume a kernel >= 5.11 is in use if busy polling is + * enabled and thus we can safely use the recvfrom() syscall + * which is only supported for AF_XDP sockets in kernels >= + * 5.11. + */ + if (rxq->busy_budget) { + (void)recvfrom(xsk_socket__fd(rxq->xsk), NULL, 0, + MSG_DONTWAIT, NULL, NULL); + } else if (xsk_ring_prod__needs_wakeup(fq)) { + (void)poll(&rxq->fds[0], 1, 1000); + } + return 0; } @@ -516,7 +527,6 @@ af_xdp_tx_zc(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) if (!xsk_ring_prod__reserve(&txq->tx, 1, &idx_tx)) { rte_pktmbuf_free(local_mbuf); - kick_tx(txq, cq); goto out; } @@ -540,10 +550,9 @@ af_xdp_tx_zc(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) tx_bytes += mbuf->pkt_len; } - kick_tx(txq, cq); - out: xsk_ring_prod__submit(&txq->tx, count); + kick_tx(txq, cq); txq->stats.tx_pkts += count; txq->stats.tx_bytes += tx_bytes; @@ -778,6 +787,38 @@ eth_dev_configure(struct rte_eth_dev *dev) return 0; } +#define CLB_VAL_IDX 0 +static int +eth_monitor_callback(const uint64_t value, + const uint64_t opaque[RTE_POWER_MONITOR_OPAQUE_SZ]) +{ + const uint64_t v = opaque[CLB_VAL_IDX]; + const uint64_t m = (uint32_t)~0; + + /* if the value has changed, abort entering power optimized state */ + return (value & m) == v ? 0 : -1; +} + +static int +eth_get_monitor_addr(void *rx_queue, struct rte_power_monitor_cond *pmc) +{ + struct pkt_rx_queue *rxq = rx_queue; + unsigned int *prod = rxq->rx.producer; + const uint32_t cur_val = rxq->rx.cached_prod; /* use cached value */ + + /* watch for changes in producer ring */ + pmc->addr = (void *)prod; + + /* store current value */ + pmc->opaque[CLB_VAL_IDX] = cur_val; + pmc->fn = eth_monitor_callback; + + /* AF_XDP producer ring index is 32-bit */ + pmc->size = sizeof(uint32_t); + + return 0; +} + static int eth_dev_info(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) { @@ -948,11 +989,6 @@ eth_dev_close(struct rte_eth_dev *dev) return 0; } -static void -eth_queue_release(void *q __rte_unused) -{ -} - static int eth_link_update(struct rte_eth_dev *dev __rte_unused, int wait_to_complete __rte_unused) @@ -1433,11 +1469,10 @@ static const struct eth_dev_ops ops = { .promiscuous_disable = eth_dev_promiscuous_disable, .rx_queue_setup = eth_rx_queue_setup, .tx_queue_setup = eth_tx_queue_setup, - .rx_queue_release = eth_queue_release, - .tx_queue_release = eth_queue_release, .link_update = eth_link_update, .stats_get = eth_stats_get, .stats_reset = eth_stats_reset, + .get_monitor_addr = eth_get_monitor_addr, }; /** parse busy_budget argument */ @@ -1748,16 +1783,11 @@ rte_pmd_af_xdp_probe(struct rte_vdev_device *dev) rte_vdev_device_name(dev)); name = rte_vdev_device_name(dev); - if (rte_eal_process_type() == RTE_PROC_SECONDARY && - strlen(rte_vdev_device_args(dev)) == 0) { - eth_dev = rte_eth_dev_attach_secondary(name); - if (eth_dev == NULL) { - AF_XDP_LOG(ERR, "Failed to probe %s\n", name); - return -EINVAL; - } - eth_dev->dev_ops = &ops; - rte_eth_dev_probing_finish(eth_dev); - return 0; + if (rte_eal_process_type() == RTE_PROC_SECONDARY) { + AF_XDP_LOG(ERR, "Failed to probe %s. " + "AF_XDP PMD does not support secondary processes.\n", + name); + return -ENOTSUP; } kvlist = rte_kvargs_parse(rte_vdev_device_args(dev), valid_arguments);