[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20191017095840.GD2861@localhost.localdomain>
Date: Thu, 17 Oct 2019 11:58:40 +0200
From: Lorenzo Bianconi <lorenzo@...nel.org>
To: Jakub Kicinski <jakub.kicinski@...ronome.com>
Cc: netdev@...r.kernel.org, lorenzo.bianconi@...hat.com,
davem@...emloft.net, thomas.petazzoni@...tlin.com,
brouer@...hat.com, ilias.apalodimas@...aro.org,
matteo.croce@...hat.com, mw@...ihalf.com
Subject: Re: [PATCH v4 net-next 2/7] net: mvneta: introduce page pool API for
sw buffer manager
> On Wed, 16 Oct 2019 23:03:07 +0200, Lorenzo Bianconi wrote:
[...]
> >
> > @@ -1894,10 +1893,11 @@ static void mvneta_rxq_drop_pkts(struct mvneta_port *pp,
> > if (!data || !(rx_desc->buf_phys_addr))
> > continue;
> >
> > - dma_unmap_page(pp->dev->dev.parent, rx_desc->buf_phys_addr,
> > - PAGE_SIZE, DMA_FROM_DEVICE);
> > - __free_page(data);
> > + page_pool_put_page(rxq->page_pool, data, false);
> > }
> > + if (xdp_rxq_info_is_reg(&rxq->xdp_rxq))
> > + xdp_rxq_info_unreg(&rxq->xdp_rxq);
> > + page_pool_destroy(rxq->page_pool);
>
> I think you may need to set the page_pool pointer to NULL here, no?
> AFAICT the ndo_stop in this driver has to be idempotent due to the
> open/close-to-reconfigure dances.
>
> > }
> >
> > static void
> > @@ -2029,8 +2029,7 @@ static int mvneta_rx_swbm(struct napi_struct *napi,
> > skb_add_rx_frag(rxq->skb, frag_num, page,
> > frag_offset, frag_size,
> > PAGE_SIZE);
> > - dma_unmap_page(dev->dev.parent, phys_addr,
> > - PAGE_SIZE, DMA_FROM_DEVICE);
> > + page_pool_release_page(rxq->page_pool, page);
> > rxq->left_size -= frag_size;
> > }
> > } else {
> > @@ -2060,9 +2059,7 @@ static int mvneta_rx_swbm(struct napi_struct *napi,
> > frag_offset, frag_size,
> > PAGE_SIZE);
> >
> > - dma_unmap_page(dev->dev.parent, phys_addr,
> > - PAGE_SIZE, DMA_FROM_DEVICE);
> > -
> > + page_pool_release_page(rxq->page_pool, page);
> > rxq->left_size -= frag_size;
> > }
> > } /* Middle or Last descriptor */
> > @@ -2829,11 +2826,53 @@ static int mvneta_poll(struct napi_struct *napi, int budget)
> > return rx_done;
> > }
> >
> > +static int mvneta_create_page_pool(struct mvneta_port *pp,
> > + struct mvneta_rx_queue *rxq, int size)
> > +{
> > + struct page_pool_params pp_params = {
> > + .order = 0,
> > + .flags = PP_FLAG_DMA_MAP,
> > + .pool_size = size,
> > + .nid = cpu_to_node(0),
> > + .dev = pp->dev->dev.parent,
> > + .dma_dir = DMA_FROM_DEVICE,
> > + };
> > + int err;
> > +
> > + rxq->page_pool = page_pool_create(&pp_params);
> > + if (IS_ERR(rxq->page_pool)) {
> > + err = PTR_ERR(rxq->page_pool);
> > + rxq->page_pool = NULL;
> > + return err;
> > + }
> > +
> > + err = xdp_rxq_info_reg(&rxq->xdp_rxq, pp->dev, rxq->id);
> > + if (err < 0)
> > + goto err_free_pp;
> > +
> > + err = xdp_rxq_info_reg_mem_model(&rxq->xdp_rxq, MEM_TYPE_PAGE_POOL,
> > + rxq->page_pool);
> > + if (err)
> > + goto err_unregister_rxq;
> > +
> > + return 0;
> > +
> > +err_unregister_rxq:
> > + xdp_rxq_info_unreg(&rxq->xdp_rxq);
> > +err_free_pp:
> > + page_pool_destroy(rxq->page_pool);
>
> ditto
>
> > + return err;
> > +}
> > +
> > /* Handle rxq fill: allocates rxq skbs; called when initializing a port */
> > static int mvneta_rxq_fill(struct mvneta_port *pp, struct mvneta_rx_queue *rxq,
> > int num)
> > {
> > - int i;
> > + int i, err;
> > +
> > + err = mvneta_create_page_pool(pp, rxq, num);
> > + if (err < 0)
> > + return err;
>
> Note that callers of mvneta_rxq_fill() never check the return code.
> Some form of error print or such could be justified here.. although
> actually propagating the error code all the way back to user space is
> even better.
ack, I agree. I will add a dedicated patch in the series.
>
> IMHO on device start the fill ring should be required to be filled up
> completely, but that's just an opinion.
at bootstrap mvneta_rxq_fill() is run with num set to rxq->size so I guess to
the max allowed value (512 by default)
Regards,
Lorenzo
>
> > for (i = 0; i < num; i++) {
> > memset(rxq->descs + i, 0, sizeof(struct mvneta_rx_desc));
Download attachment "signature.asc" of type "application/pgp-signature" (229 bytes)
Powered by blists - more mailing lists