Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 167cebef authored by John Hurley's avatar John Hurley Committed by David S. Miller
Browse files

nfp: modify app MTU setting callbacks



Rename the 'change_mtu' app callback to 'check_mtu'. This is called
whenever an MTU change is requested on a netdev. It can reject the
change but is not responsible for implementing it.

Introduce a new 'repr_change_mtu' app callback that is hit when the MTU
of a repr is to be changed. This is responsible for performing the MTU
change and verifying it.

Signed-off-by: default avatarJohn Hurley <john.hurley@netronome.com>
Reviewed-by: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 44465c47
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -221,7 +221,7 @@ static int nfp_bpf_setup_tc(struct nfp_app *app, struct net_device *netdev,
}

static int
nfp_bpf_change_mtu(struct nfp_app *app, struct net_device *netdev, int new_mtu)
nfp_bpf_check_mtu(struct nfp_app *app, struct net_device *netdev, int new_mtu)
{
	struct nfp_net *nn = netdev_priv(netdev);
	unsigned int max_mtu;
@@ -413,7 +413,7 @@ const struct nfp_app_type app_bpf = {
	.init		= nfp_bpf_init,
	.clean		= nfp_bpf_clean,

	.change_mtu	= nfp_bpf_change_mtu,
	.check_mtu	= nfp_bpf_check_mtu,

	.extra_cap	= nfp_bpf_extra_cap,

+18 −7
Original line number Diff line number Diff line
@@ -86,8 +86,8 @@ extern const struct nfp_app_type app_flower;
 * @repr_clean:	representor about to be unregistered
 * @repr_open:	representor netdev open callback
 * @repr_stop:	representor netdev stop callback
 * @change_mtu:	MTU change on a netdev has been requested (veto-only, change
 *		is not guaranteed to be committed)
 * @check_mtu:	MTU change request on a netdev (verify it is valid)
 * @repr_change_mtu:	MTU change request on repr (make and verify change)
 * @start:	start application logic
 * @stop:	stop application logic
 * @ctrl_msg_rx:    control message handler
@@ -124,7 +124,9 @@ struct nfp_app_type {
	int (*repr_open)(struct nfp_app *app, struct nfp_repr *repr);
	int (*repr_stop)(struct nfp_app *app, struct nfp_repr *repr);

	int (*change_mtu)(struct nfp_app *app, struct net_device *netdev,
	int (*check_mtu)(struct nfp_app *app, struct net_device *netdev,
			 int new_mtu);
	int (*repr_change_mtu)(struct nfp_app *app, struct net_device *netdev,
			       int new_mtu);

	int (*start)(struct nfp_app *app);
@@ -247,11 +249,20 @@ nfp_app_repr_clean(struct nfp_app *app, struct net_device *netdev)
}

static inline int
nfp_app_change_mtu(struct nfp_app *app, struct net_device *netdev, int new_mtu)
nfp_app_check_mtu(struct nfp_app *app, struct net_device *netdev, int new_mtu)
{
	if (!app || !app->type->check_mtu)
		return 0;
	return app->type->check_mtu(app, netdev, new_mtu);
}

static inline int
nfp_app_repr_change_mtu(struct nfp_app *app, struct net_device *netdev,
			int new_mtu)
{
	if (!app || !app->type->change_mtu)
	if (!app || !app->type->repr_change_mtu)
		return 0;
	return app->type->change_mtu(app, netdev, new_mtu);
	return app->type->repr_change_mtu(app, netdev, new_mtu);
}

static inline int nfp_app_start(struct nfp_app *app, struct nfp_net *ctrl)
+1 −1
Original line number Diff line number Diff line
@@ -3066,7 +3066,7 @@ static int nfp_net_change_mtu(struct net_device *netdev, int new_mtu)
	struct nfp_net_dp *dp;
	int err;

	err = nfp_app_change_mtu(nn->app, netdev, new_mtu);
	err = nfp_app_check_mtu(nn->app, netdev, new_mtu);
	if (err)
		return err;

+12 −1
Original line number Diff line number Diff line
@@ -196,8 +196,19 @@ nfp_repr_get_offload_stats(int attr_id, const struct net_device *dev,
static int nfp_repr_change_mtu(struct net_device *netdev, int new_mtu)
{
	struct nfp_repr *repr = netdev_priv(netdev);
	int err;

	return nfp_app_change_mtu(repr->app, netdev, new_mtu);
	err = nfp_app_check_mtu(repr->app, netdev, new_mtu);
	if (err)
		return err;

	err = nfp_app_repr_change_mtu(repr->app, netdev, new_mtu);
	if (err)
		return err;

	netdev->mtu = new_mtu;

	return 0;
}

static netdev_tx_t nfp_repr_xmit(struct sk_buff *skb, struct net_device *netdev)