From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id BCC95A0C54 for ; Fri, 3 Sep 2021 18:15:29 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id AD12540E78; Fri, 3 Sep 2021 18:15:29 +0200 (CEST) Received: from mail-pf1-f169.google.com (mail-pf1-f169.google.com [209.85.210.169]) by mails.dpdk.org (Postfix) with ESMTP id F22E340E78 for ; Fri, 3 Sep 2021 18:15:28 +0200 (CEST) Received: by mail-pf1-f169.google.com with SMTP id u6so4679692pfi.0 for ; Fri, 03 Sep 2021 09:15:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=iluUsGSmUiHoq9v45v6iUEi3M3DCdNXxvZ4cTBbXWyY=; b=jTMihZZT8+rjwiVWqubgdiz528X5KINbkZb6FL3kvo9aEcO5r1ZuRBkqVCuCJhJneS XoethRLLK+bG4ajO9zf85b6wK5PZs7wMjiradN29JgU5Hi7tKlOHrTn8hByOyfRoxkZX Ji+94t9kMT5XImBY0vM4V7KZF+dnL1l22YGWDKPQtmFd4NNdQlmve63uO6wLr49KPVoY W6EXIamE/U4FfHTJhR7hG4OakSwONGJs6TM0Ighw4MSB4Wy+5VyqRCMEbgCeTIfeyJFJ apeiAGXZENx3YI0SfuxISLrXnUOnDPQNdq4kkQ2E+CAGYRTkChWH6E6uHE6Md9nbdvp9 7VQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=iluUsGSmUiHoq9v45v6iUEi3M3DCdNXxvZ4cTBbXWyY=; b=btfDY9FQLd/+iwNCx5pm4je7OrPMjZNVZSWKk72b3FnkBKtfsWu+wz5OAwM0tMQvNv iiObTjaI/TCrJwlDRt3AFFLj5yU+KO5hVrYeGMTG7bm1U4OHOZOjOWLQkuEZmbbqveTR EPbyp4qEXxPrpUDW93lHVyNhcyfmfN0lFAWZ/YeNA2tWD/dTFkh2nKngTv6MyXNosPAa HLPDDe0WrR/kDMU+pcFpcRwL+kZhhb0s+xGFdfoijbYBk2OX8J/a/xvvbtUyQiT5JiS2 kvjX8DqWcpmmtIAU/LIz+FDt3xrfQPARqvn7fhqlFkFdlzlEJi4/4UkPz5fUJApPgtY+ /F/A== X-Gm-Message-State: AOAM531P+PSp+psX5selE7BPKfgifKzWgDdEIeeKNf8yz5n93tgSZUeQ URckhsXrP9xnxwuMGbrcckQQ6w== X-Google-Smtp-Source: ABdhPJxTtpC6814GTNPx17WVAEb29X23ncGLF+8VbI6ixaJCIZwi2Vy45L8KcUaVtkQsnh1ibGMSTg== X-Received: by 2002:a62:9288:0:b0:3e1:c44f:a1b7 with SMTP id o130-20020a629288000000b003e1c44fa1b7mr4076247pfd.63.1630685728090; Fri, 03 Sep 2021 09:15:28 -0700 (PDT) Received: from hermes.local (204-195-33-123.wavecable.com. [204.195.33.123]) by smtp.gmail.com with ESMTPSA id s15sm5827292pjk.21.2021.09.03.09.15.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Sep 2021 09:15:27 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , stable@dpdk.org, xiaolong.ye@intel.com Date: Fri, 3 Sep 2021 09:15:25 -0700 Message-Id: <20210903161525.9929-1-stephen@networkplumber.org> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] [PATCH] net/af_xdp: fix support of secondary process X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" Doing basic operations like info_get or get_stats was broken in af_xdp PMD. The info_get would crash because dev->device was NULL in secondary process. Fix this by doing same initialization as af_packet and tap devices. The get_stats would crash because the XDP socket is not open in primary process. As a workaround don't query kernel for dropped packets when called from secondary process. Note: this does not address the other bug which is that transmitting in secondary process is broken because the send() in tx_kick will fail because XDP socket fd is not valid in secondary process. Bugzilla ID: 805 Fixes: f1debd77efaf ("net/af_xdp: introduce AF_XDP PMD") Cc: stable@dpdk.org Cc: xiaolong.ye@intel.com Ciara Loftus Qi Zhang Anatoly Burakov Signed-off-by: Stephen Hemminger --- drivers/net/af_xdp/rte_eth_af_xdp.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/net/af_xdp/rte_eth_af_xdp.c b/drivers/net/af_xdp/rte_eth_af_xdp.c index 74ffa4511284..70abc14fa753 100644 --- a/drivers/net/af_xdp/rte_eth_af_xdp.c +++ b/drivers/net/af_xdp/rte_eth_af_xdp.c @@ -860,7 +860,7 @@ eth_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) struct pkt_rx_queue *rxq; struct pkt_tx_queue *txq; socklen_t optlen; - int i, ret; + int i; for (i = 0; i < dev->data->nb_rx_queues; i++) { optlen = sizeof(struct xdp_statistics); @@ -876,13 +876,12 @@ eth_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) stats->ibytes += stats->q_ibytes[i]; stats->imissed += rxq->stats.rx_dropped; stats->oerrors += txq->stats.tx_dropped; - ret = getsockopt(xsk_socket__fd(rxq->xsk), SOL_XDP, - XDP_STATISTICS, &xdp_stats, &optlen); - if (ret != 0) { - AF_XDP_LOG(ERR, "getsockopt() failed for XDP_STATISTICS.\n"); - return -1; - } - stats->imissed += xdp_stats.rx_dropped; + + /* The socket fd is not valid in secondary process */ + if (rte_eal_process_type() != RTE_PROC_SECONDARY && + getsockopt(xsk_socket__fd(rxq->xsk), SOL_XDP, + XDP_STATISTICS, &xdp_stats, &optlen) == 0) + stats->imissed += xdp_stats.rx_dropped; stats->opackets += stats->q_opackets[i]; stats->obytes += stats->q_obytes[i]; @@ -1799,7 +1798,9 @@ rte_pmd_af_xdp_probe(struct rte_vdev_device *dev) AF_XDP_LOG(ERR, "Failed to probe %s\n", name); return -EINVAL; } + /* TODO: reconnect socket from primary */ eth_dev->dev_ops = &ops; + eth_dev->device = &dev->device; rte_eth_dev_probing_finish(eth_dev); return 0; } -- 2.30.2