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

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
...@@ -221,7 +221,7 @@ static int nfp_bpf_setup_tc(struct nfp_app *app, struct net_device *netdev, ...@@ -221,7 +221,7 @@ static int nfp_bpf_setup_tc(struct nfp_app *app, struct net_device *netdev,
} }
static int 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); struct nfp_net *nn = netdev_priv(netdev);
unsigned int max_mtu; unsigned int max_mtu;
...@@ -413,7 +413,7 @@ const struct nfp_app_type app_bpf = { ...@@ -413,7 +413,7 @@ const struct nfp_app_type app_bpf = {
.init = nfp_bpf_init, .init = nfp_bpf_init,
.clean = nfp_bpf_clean, .clean = nfp_bpf_clean,
.change_mtu = nfp_bpf_change_mtu, .check_mtu = nfp_bpf_check_mtu,
.extra_cap = nfp_bpf_extra_cap, .extra_cap = nfp_bpf_extra_cap,
......
...@@ -86,8 +86,8 @@ extern const struct nfp_app_type app_flower; ...@@ -86,8 +86,8 @@ extern const struct nfp_app_type app_flower;
* @repr_clean: representor about to be unregistered * @repr_clean: representor about to be unregistered
* @repr_open: representor netdev open callback * @repr_open: representor netdev open callback
* @repr_stop: representor netdev stop callback * @repr_stop: representor netdev stop callback
* @change_mtu: MTU change on a netdev has been requested (veto-only, change * @check_mtu: MTU change request on a netdev (verify it is valid)
* is not guaranteed to be committed) * @repr_change_mtu: MTU change request on repr (make and verify change)
* @start: start application logic * @start: start application logic
* @stop: stop application logic * @stop: stop application logic
* @ctrl_msg_rx: control message handler * @ctrl_msg_rx: control message handler
...@@ -124,8 +124,10 @@ struct nfp_app_type { ...@@ -124,8 +124,10 @@ struct nfp_app_type {
int (*repr_open)(struct nfp_app *app, struct nfp_repr *repr); int (*repr_open)(struct nfp_app *app, struct nfp_repr *repr);
int (*repr_stop)(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 new_mtu);
int (*repr_change_mtu)(struct nfp_app *app, struct net_device *netdev,
int new_mtu);
int (*start)(struct nfp_app *app); int (*start)(struct nfp_app *app);
void (*stop)(struct nfp_app *app); void (*stop)(struct nfp_app *app);
...@@ -247,11 +249,20 @@ nfp_app_repr_clean(struct nfp_app *app, struct net_device *netdev) ...@@ -247,11 +249,20 @@ nfp_app_repr_clean(struct nfp_app *app, struct net_device *netdev)
} }
static inline int 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 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) static inline int nfp_app_start(struct nfp_app *app, struct nfp_net *ctrl)
......
...@@ -3066,7 +3066,7 @@ static int nfp_net_change_mtu(struct net_device *netdev, int new_mtu) ...@@ -3066,7 +3066,7 @@ static int nfp_net_change_mtu(struct net_device *netdev, int new_mtu)
struct nfp_net_dp *dp; struct nfp_net_dp *dp;
int err; int err;
err = nfp_app_change_mtu(nn->app, netdev, new_mtu); err = nfp_app_check_mtu(nn->app, netdev, new_mtu);
if (err) if (err)
return err; return err;
......
...@@ -196,8 +196,19 @@ nfp_repr_get_offload_stats(int attr_id, const struct net_device *dev, ...@@ -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) static int nfp_repr_change_mtu(struct net_device *netdev, int new_mtu)
{ {
struct nfp_repr *repr = netdev_priv(netdev); 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) static netdev_tx_t nfp_repr_xmit(struct sk_buff *skb, struct net_device *netdev)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment