All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lorenzo Bianconi <lorenzo@kernel.org>
To: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Cc: netdev@vger.kernel.org, thomas.petazzoni@bootlin.com,
	brouer@redhat.com, mcroce@redhat.com
Subject: Re: [RFC 3/4] net: mvneta: add basic XDP support
Date: Wed, 2 Oct 2019 10:59:33 +0200	[thread overview]
Message-ID: <20191002085933.GA2527@localhost.localdomain> (raw)
In-Reply-To: <20191002034154.GA15959@apalos.home>

[-- Attachment #1: Type: text/plain, Size: 4596 bytes --]

> On Tue, Oct 01, 2019 at 11:24:43AM +0200, Lorenzo Bianconi wrote:
> > Add basic XDP support to mvneta driver for devices that rely on software
> > buffer management. Currently supported verdicts are:
> > - XDP_DROP
> > - XDP_PASS
> > - XDP_REDIRECT
> > 
> > Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
> > ---
> >  drivers/net/ethernet/marvell/mvneta.c | 145 ++++++++++++++++++++++++--
> >  1 file changed, 136 insertions(+), 9 deletions(-)
> > 
> > diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c
> > index e842c744e4f3..f2d12556efa8 100644
> > --- a/drivers/net/ethernet/marvell/mvneta.c
> > +++ b/drivers/net/ethernet/marvell/mvneta.c
> [...]
> >  		.pool_size = size,
> >  		.nid = cpu_to_node(0),
> >  		.dev = pp->dev->dev.parent,
> > -		.dma_dir = DMA_FROM_DEVICE,
> > +		.dma_dir = xdp_prog ? DMA_BIDIRECTIONAL : DMA_FROM_DEVICE,
> >  	};
> > +	int err;
> >  
> >  	rxq->page_pool = page_pool_create(&pp_params);
> >  	if (IS_ERR(rxq->page_pool)) {
> > @@ -2851,7 +2920,22 @@ static int mvneta_create_page_pool(struct mvneta_port *pp,
> >  		return PTR_ERR(rxq->page_pool);
> >  	}
> >  
> > +	err = xdp_rxq_info_reg(&rxq->xdp_rxq, pp->dev, 0);
> > +	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_pp;
> 
> I think this should be part of patch [1/4], adding page pol support. 
> Jesper introduced the changes to track down inflight packets [1], so you need
> those changes in place when implementing page_pool

ack, will do in the next round.

Regards,
Lorenzo

> 
> > +
> >  	return 0;
> > +
> > +err_unregister_pp:
> > +	xdp_rxq_info_unreg(&rxq->xdp_rxq);
> > +err_free_pp:
> > +	page_pool_destroy(rxq->page_pool);
> > +	return err;
> >  }
> >  
> >  /* Handle rxq fill: allocates rxq skbs; called when initializing a port */
> > @@ -3291,6 +3375,11 @@ static int mvneta_change_mtu(struct net_device *dev, int mtu)
> >  		mtu = ALIGN(MVNETA_RX_PKT_SIZE(mtu), 8);
> >  	}
> >  
> > +	if (pp->xdp_prog && mtu > MVNETA_MAX_RX_BUF_SIZE) {
> > +		netdev_info(dev, "Illegal MTU value %d for XDP mode\n", mtu);
> > +		return -EINVAL;
> > +	}
> > +
> >  	dev->mtu = mtu;
> >  
> >  	if (!netif_running(dev)) {
> > @@ -3960,6 +4049,43 @@ static int mvneta_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
> >  	return phylink_mii_ioctl(pp->phylink, ifr, cmd);
> >  }
> >  
> > +static int mvneta_xdp_setup(struct net_device *dev, struct bpf_prog *prog,
> > +			    struct netlink_ext_ack *extack)
> > +{
> > +	struct mvneta_port *pp = netdev_priv(dev);
> > +	struct bpf_prog *old_prog;
> > +
> > +	if (prog && dev->mtu > MVNETA_MAX_RX_BUF_SIZE) {
> > +		NL_SET_ERR_MSG_MOD(extack, "Jumbo frames not supported on XDP");
> > +		return -EOPNOTSUPP;
> > +	}
> > +
> > +	mvneta_stop(dev);
> > +
> > +	old_prog = xchg(&pp->xdp_prog, prog);
> > +	if (old_prog)
> > +		bpf_prog_put(old_prog);
> > +
> > +	mvneta_open(dev);
> > +
> > +	return 0;
> > +}
> > +
> > +static int mvneta_xdp(struct net_device *dev, struct netdev_bpf *xdp)
> > +{
> > +	struct mvneta_port *pp = netdev_priv(dev);
> > +
> > +	switch (xdp->command) {
> > +	case XDP_SETUP_PROG:
> > +		return mvneta_xdp_setup(dev, xdp->prog, xdp->extack);
> > +	case XDP_QUERY_PROG:
> > +		xdp->prog_id = pp->xdp_prog ? pp->xdp_prog->aux->id : 0;
> > +		return 0;
> > +	default:
> > +		return -EINVAL;
> > +	}
> > +}
> > +
> >  /* Ethtool methods */
> >  
> >  /* Set link ksettings (phy address, speed) for ethtools */
> > @@ -4356,6 +4482,7 @@ static const struct net_device_ops mvneta_netdev_ops = {
> >  	.ndo_fix_features    = mvneta_fix_features,
> >  	.ndo_get_stats64     = mvneta_get_stats64,
> >  	.ndo_do_ioctl        = mvneta_ioctl,
> > +	.ndo_bpf	     = mvneta_xdp,
> >  };
> >  
> >  static const struct ethtool_ops mvneta_eth_tool_ops = {
> > @@ -4646,7 +4773,7 @@ static int mvneta_probe(struct platform_device *pdev)
> >  	SET_NETDEV_DEV(dev, &pdev->dev);
> >  
> >  	pp->id = global_port_id++;
> > -	pp->rx_offset_correction = NET_SKB_PAD;
> > +	pp->rx_offset_correction = MVNETA_SKB_HEADROOM;
> >  
> >  	/* Obtain access to BM resources if enabled and already initialized */
> >  	bm_node = of_parse_phandle(dn, "buffer-manager", 0);
> > -- 
> > 2.21.0
> > 
> 
> [1] https://lore.kernel.org/netdev/156086304827.27760.11339786046465638081.stgit@firesoul/
> 
> 
> Regards
> /Ilias

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

  reply	other threads:[~2019-10-02  8:59 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-01  9:24 [RFC 0/4] add basic XDP support to mvneta driver Lorenzo Bianconi
2019-10-01  9:24 ` [RFC 1/4] net: mvneta: introduce page pool API for sw buffer manager Lorenzo Bianconi
2019-10-01 14:11   ` kbuild test robot
2019-10-01  9:24 ` [RFC 2/4] net: mvneta: rely on build_skb in mvneta_rx_swbm poll routine Lorenzo Bianconi
2019-10-01  9:24 ` [RFC 3/4] net: mvneta: add basic XDP support Lorenzo Bianconi
2019-10-01 10:37   ` Matteo Croce
2019-10-01 11:02     ` Toke Høiland-Jørgensen
2019-10-01 10:52   ` Maciej Fijalkowski
2019-10-01 11:06     ` Toke Høiland-Jørgensen
2019-10-01 11:30       ` Jesper Dangaard Brouer
2019-10-01 11:47         ` Lorenzo Bianconi
2019-10-01 11:44     ` Lorenzo Bianconi
2019-10-02  3:41   ` Ilias Apalodimas
2019-10-02  8:59     ` Lorenzo Bianconi [this message]
2019-10-01  9:24 ` [RFC 4/4] net: mvneta: move header prefetch in mvneta_swbm_rx_frame Lorenzo Bianconi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191002085933.GA2527@localhost.localdomain \
    --to=lorenzo@kernel.org \
    --cc=brouer@redhat.com \
    --cc=ilias.apalodimas@linaro.org \
    --cc=mcroce@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=thomas.petazzoni@bootlin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.