From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id 6EA52A00E6 for ; Thu, 13 Jun 2019 02:33:23 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 7C3E91D014; Thu, 13 Jun 2019 02:33:22 +0200 (CEST) Received: from mail-qk1-f196.google.com (mail-qk1-f196.google.com [209.85.222.196]) by dpdk.org (Postfix) with ESMTP id D9F6D1D00A for ; Thu, 13 Jun 2019 02:33:20 +0200 (CEST) Received: by mail-qk1-f196.google.com with SMTP id g18so11645312qkl.3 for ; Wed, 12 Jun 2019 17:33:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=+gDJfUXOZQyDME56a4DdWw6P6Zme0jRvYKbVoGsOhWE=; b=K/FcrLOm95BqSMEvFZOCwh5EB4s5dOjXwZE/asx0/mU0ONNxjNauqiR3/+nleKgRaU eq6u23vmuTOSj4GkO2tucwCq+IkgLoKkYbXQaEcXYowz0VpL1Bu5FBjw9+GO85eTxofS AhHiRi775UQO5+hVg8EZxojSqycP+fkZJSO2+NJtRo5G+lGBdoawruG9X6oCVE3WyfP6 pUAR/RXw3D+v2s//2olEQwvCn727nSdwbEaNv2/crtboZk6BBvGqptLsSCCBHi7lPWaE S0zHvyD0FI7TqIYD0O6FGkDL6iG+ge0x0bBmPunEPara0OzE9lrDUrGHQUcfdW4f5/Yr ML4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=+gDJfUXOZQyDME56a4DdWw6P6Zme0jRvYKbVoGsOhWE=; b=TrX7xPySVXauKHeVolU3eru2qYfrZIh0QYFpiSv0yacr8B4Xw2GEeQ5Pa0JC0orqTJ XoqU4eB07pnCb8HtrurTYZkQZEcm+yZBbHs6yL0LppDug1QspZBRuo+eZ9a8PJW7yqn7 VXqyEeKcRD8lJIHAov0jLKAbs+rLkwn1UMFLHwdKhPUQ7Kqb1vdNAv0lYMRLcFUlGtYn z0IYrn98a22HWVgjXYCbKhqLtK4+RKY19aLGNwBv12/pr2fQT/5zseIkJGwr3u3rvMAI bDHUOq2rxzaphkk7ORJmiqwVWUFJ4P4t8R5L7LB6VDJStQFuCn/3UioeuWqDoEihBz8f iF1w== X-Gm-Message-State: APjAAAVFtqJd4ZCgnRt30su4AVwnU1voRrlRh9GdlUdc7Y+M8JOSNDRZ JbZtyh2g1oLJQzM7SuYEXW0f3I6BGJ0oxvl9akc= X-Google-Smtp-Source: APXvYqyFN4I9vrY4OxmL+ddzSqgd0rOAnsTTWDZD4ZTL4K8YerM301otO2edVSQ5inLLr8yzeyQptpYojXwkqHi1aoo= X-Received: by 2002:a05:620a:1456:: with SMTP id i22mr44316439qkl.170.1560386000154; Wed, 12 Jun 2019 17:33:20 -0700 (PDT) MIME-Version: 1.0 References: <20190515083842.15116-1-xiaolong.ye@intel.com> <20190530090707.36290-1-xiaolong.ye@intel.com> <20190530090707.36290-2-xiaolong.ye@intel.com> <20190612100339.GA32720@intel.com> In-Reply-To: <20190612100339.GA32720@intel.com> From: William Tu Date: Wed, 12 Jun 2019 17:32:41 -0700 Message-ID: To: Ye Xiaolong Cc: Qi Zhang , John McNamara , Marko Kovacevic , Karlsson Magnus , Topel Bjorn , dev@dpdk.org Content-Type: text/plain; charset="UTF-8" Subject: Re: [dpdk-dev] [PATCH v2 1/3] net/af_xdp: enable zero copy by extbuf X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 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" On Tue, Jun 11, 2019 at 8:21 PM Ye Xiaolong wrote: > > Hi, > > On 06/11, William Tu wrote: > [snip] > >> @@ -294,16 +326,26 @@ eth_af_xdp_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) > >> > >> desc = xsk_ring_prod__tx_desc(&txq->tx, idx_tx + i); > >> mbuf = bufs[i]; > >> - > >> - desc->addr = (uint64_t)addrs[i]; > >> desc->len = mbuf->pkt_len; > >> - pkt = xsk_umem__get_data(umem->mz->addr, > >> - desc->addr); > >> - rte_memcpy(pkt, rte_pktmbuf_mtod(mbuf, void *), > >> - desc->len); > >> - tx_bytes += mbuf->pkt_len; > >> > >> - rte_pktmbuf_free(mbuf); > >> + /* > >> + * We need to make sure the external mbuf address is within > >> + * current port's umem memzone range > >> + */ > >> + if (pmd_zc && RTE_MBUF_HAS_EXTBUF(mbuf) && > >> + in_umem_range(umem, (uint64_t)mbuf->buf_addr)) { > >> + desc->addr = (uint64_t)mbuf->buf_addr - > >> + umem->mz->addr_64; > >> + mbuf->buf_addr = xsk_umem__get_data(umem->mz->addr, > >> + (uint64_t)addrs[i]); > >> + } else { > >> + desc->addr = (uint64_t)addrs[i]; > >> + pkt = xsk_umem__get_data(umem->mz->addr, > >> + desc->addr); > >> + rte_memcpy(pkt, rte_pktmbuf_mtod(mbuf, void *), > >> + desc->len); > >> + } > >> + tx_bytes += mbuf->pkt_len; > >> } > >> > >> xsk_ring_prod__submit(&txq->tx, nb_pkts); > >> @@ -313,6 +355,9 @@ eth_af_xdp_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) > >> txq->stats.tx_pkts += nb_pkts; > >> txq->stats.tx_bytes += tx_bytes; > >> > >> + for (i = 0; i < nb_pkts; i++) > >> + rte_pktmbuf_free(bufs[i]); > >> + > > > >Is it ok to free the mbuf here? > >If the AF_XDP is running pmd_zc=true, the packet mbuf is still in the tx > >ring and might not be sent out yet. > > For pmd_zc=ture case, here mbuf->buf_addr has been exchanged to available addr > dequeued from umem->buf_ring, rte_pktmbuf_free would just call the free callback > umem_buf_release_to_fq to enqueue the addr to the buf_ring. > I see, thanks for the explanation. William > Thanks, > Xiaolong > > > > >Regards, > >William > >