]> Git Repo - linux.git/commitdiff
nfp: modify app MTU setting callbacks
authorJohn Hurley <[email protected]>
Thu, 29 Mar 2018 01:50:06 +0000 (18:50 -0700)
committerDavid S. Miller <[email protected]>
Fri, 30 Mar 2018 14:18:54 +0000 (10:18 -0400)
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 <[email protected]>
Reviewed-by: Jakub Kicinski <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
drivers/net/ethernet/netronome/nfp/bpf/main.c
drivers/net/ethernet/netronome/nfp/nfp_app.h
drivers/net/ethernet/netronome/nfp/nfp_net_common.c
drivers/net/ethernet/netronome/nfp/nfp_net_repr.c

index 34e98aa6b95623b354e99d4235962cabec59d700..752c45763ed90c7aa55836d662fc5da9218c6e0e 100644 (file)
@@ -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,
 
index 20546ae67909027c641a1df46e95e18fa979f456..2d9cb2528fc7fb7bae771f13fbc5a4b1e65e13bb 100644 (file)
@@ -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,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);
@@ -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)
index a05be0ab27134d7cfaf16f8ef196b5355f02eadd..43a9c207a04959c8eb4c61cc417abe2bb8f8f3ca 100644 (file)
@@ -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;
 
index 619570524d2a4989fc0c91c25c42289f90ecd9c7..0cd077addb26a5bd666a15d3d1c361186d8f8678 100644 (file)
@@ -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)
This page took 0.071082 seconds and 4 git commands to generate.