Skip to content

Commit

Permalink
nfp: modify app MTU setting callbacks
Browse files Browse the repository at this point in the history
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: John Hurley <john.hurley@netronome.com>
Reviewed-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
John Hurley authored and David S. Miller committed Mar 30, 2018
1 parent 44465c4 commit 167cebe
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 11 deletions.
4 changes: 2 additions & 2 deletions drivers/net/ethernet/netronome/nfp/bpf/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,

Expand Down
25 changes: 18 additions & 7 deletions drivers/net/ethernet/netronome/nfp/nfp_app.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -124,8 +124,10 @@ 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 new_mtu);
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);
void (*stop)(struct nfp_app *app);
Expand Down Expand Up @@ -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->change_mtu)
if (!app || !app->type->check_mtu)
return 0;
return app->type->change_mtu(app, netdev, new_mtu);
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->repr_change_mtu)
return 0;
return app->type->repr_change_mtu(app, netdev, new_mtu);
}

static inline int nfp_app_start(struct nfp_app *app, struct nfp_net *ctrl)
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/ethernet/netronome/nfp/nfp_net_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
13 changes: 12 additions & 1 deletion drivers/net/ethernet/netronome/nfp/nfp_net_repr.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 167cebe

Please sign in to comment.