From patchwork Fri Sep 3 16:15:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 97952 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id EB67DA0C54; Fri, 3 Sep 2021 18:15:30 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D802641167; Fri, 3 Sep 2021 18:15:30 +0200 (CEST) Received: from mail-pg1-f180.google.com (mail-pg1-f180.google.com [209.85.215.180]) by mails.dpdk.org (Postfix) with ESMTP id 78BF740E78 for ; Fri, 3 Sep 2021 18:15:29 +0200 (CEST) Received: by mail-pg1-f180.google.com with SMTP id r2so5980871pgl.10 for ; Fri, 03 Sep 2021 09:15:29 -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=bltKHmxwGgGEyPVe+vgcNuKqKy4FRYqXFr50atJyWUMPEyXDL+mwGcqSDPd27I+0zB rgx7vZ7+Aq3KxpNvz8SIgyNiVkn8qmupSZi4k6uEDMZAv9T+QyNHiPQcxZD5DPyaicFn XHtjgNTNYmHHc0K9Lq5WGH6rxdLIcCIVJiC1jvsdqoYBhETeQtJg2yt87TVYsX3pWzzC 3JgM6A8soYCP09D5wejlYTfQp3ES9+Ohdp1o7ZlIQ9s60T+rXpQWgtB7+GNtiTj0773N ob8pzWgEuPKKVh4Ihx7jQJoTWPmOXrAdQcvIyk3PJlW3sTmr3EwbhEbQ53u+O9nuSOu1 j0sA== X-Gm-Message-State: AOAM5306wU/PFCagwxLADocZqGwV1FiE9OePS6ArzJjxowyUkuH+bfSP xdPWTJOpdqmiA0h9bs2ra4rJP6qKau6SJw== 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 Subject: [dpdk-dev] [PATCH] net/af_xdp: fix support of secondary process X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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; }