Message ID | 20180425041704.26882-5-jakub.kicinski@netronome.com |
---|---|
State | Accepted, archived |
Delegated to: | David Miller |
Headers | show |
Series | nfp: flower tc block support and nfp PCI updates | expand |
On Wed, Apr 25, 2018 at 7:17 AM, Jakub Kicinski <jakub.kicinski@netronome.com> wrote: > From: John Hurley <john.hurley@netronome.com> > > If a flower rule has a repr both as ingress and egress port then 2 > callbacks may be generated for the same rule request. > > Add an indicator to each flow as to whether or not it was added from an > ingress registered cb. If so then ignore add/del/stat requests to it from > an egress cb. So on add() you ignore (return success) - I wasn't sure from the patch what do you do for stat()/del() -- success? why not err? as you know I am working on the same patch for mlx5, lets align here please. Or.
On Wed, Apr 25, 2018 at 10:17 AM, Or Gerlitz <gerlitz.or@gmail.com> wrote: > On Wed, Apr 25, 2018 at 7:17 AM, Jakub Kicinski > <jakub.kicinski@netronome.com> wrote: >> From: John Hurley <john.hurley@netronome.com> >> >> If a flower rule has a repr both as ingress and egress port then 2 >> callbacks may be generated for the same rule request. >> >> Add an indicator to each flow as to whether or not it was added from an >> ingress registered cb. If so then ignore add/del/stat requests to it from >> an egress cb. > > So on add() you ignore (return success) - I wasn't sure from the patch > what do you do for stat()/del() -- success? why not err? as you know I am > working on the same patch for mlx5, lets align here please. > > Or. ok, this is way Ive implemented the calls... add: - if egress cb duplicate but the flow has been added on ingress cb then ignore (return success) - if egress cb duplicate and flow not added on ingress then err (this is a 'true duplicate') stats: - if egress cb but the flow has an ingress cb then ignore - stat request will have been covered on ingress cb so shouldn't error, just don't repeat del: - if egress cb and flow no longer exists then assume it was deleted on ingress so ignore (return success) - if ingress cb and flow no longer exists then (as ingress cb is hit first) this is a bad request whereby trying to delete a flow that was never added - return err
diff --git a/drivers/net/ethernet/netronome/nfp/flower/main.h b/drivers/net/ethernet/netronome/nfp/flower/main.h index 9e6804bc9b40..733ff53cc601 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/main.h +++ b/drivers/net/ethernet/netronome/nfp/flower/main.h @@ -194,6 +194,7 @@ struct nfp_fl_payload { char *unmasked_data; char *mask_data; char *action_data; + bool ingress_offload; }; struct nfp_fl_stats_frame { diff --git a/drivers/net/ethernet/netronome/nfp/flower/offload.c b/drivers/net/ethernet/netronome/nfp/flower/offload.c index bdc82e11a31e..70ec9d821b91 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/offload.c +++ b/drivers/net/ethernet/netronome/nfp/flower/offload.c @@ -345,7 +345,7 @@ nfp_flower_calculate_key_layers(struct nfp_app *app, } static struct nfp_fl_payload * -nfp_flower_allocate_new(struct nfp_fl_key_ls *key_layer) +nfp_flower_allocate_new(struct nfp_fl_key_ls *key_layer, bool egress) { struct nfp_fl_payload *flow_pay; @@ -371,6 +371,8 @@ nfp_flower_allocate_new(struct nfp_fl_key_ls *key_layer) flow_pay->meta.flags = 0; spin_lock_init(&flow_pay->lock); + flow_pay->ingress_offload = !egress; + return flow_pay; err_free_mask: @@ -402,8 +404,20 @@ nfp_flower_add_offload(struct nfp_app *app, struct net_device *netdev, struct nfp_flower_priv *priv = app->priv; struct nfp_fl_payload *flow_pay; struct nfp_fl_key_ls *key_layer; + struct net_device *ingr_dev; int err; + ingr_dev = egress ? NULL : netdev; + flow_pay = nfp_flower_search_fl_table(app, flow->cookie, ingr_dev, + NFP_FL_STATS_CTX_DONT_CARE); + if (flow_pay) { + /* Ignore as duplicate if it has been added by different cb. */ + if (flow_pay->ingress_offload && egress) + return 0; + else + return -EOPNOTSUPP; + } + key_layer = kmalloc(sizeof(*key_layer), GFP_KERNEL); if (!key_layer) return -ENOMEM; @@ -413,7 +427,7 @@ nfp_flower_add_offload(struct nfp_app *app, struct net_device *netdev, if (err) goto err_free_key_ls; - flow_pay = nfp_flower_allocate_new(key_layer); + flow_pay = nfp_flower_allocate_new(key_layer, egress); if (!flow_pay) { err = -ENOMEM; goto err_free_key_ls; @@ -485,7 +499,7 @@ nfp_flower_del_offload(struct nfp_app *app, struct net_device *netdev, nfp_flow = nfp_flower_search_fl_table(app, flow->cookie, ingr_dev, NFP_FL_STATS_CTX_DONT_CARE); if (!nfp_flow) - return -ENOENT; + return egress ? 0 : -ENOENT; err = nfp_modify_flow_metadata(app, nfp_flow); if (err) @@ -534,6 +548,9 @@ nfp_flower_get_stats(struct nfp_app *app, struct net_device *netdev, if (!nfp_flow) return -EINVAL; + if (nfp_flow->ingress_offload && egress) + return 0; + spin_lock_bh(&nfp_flow->lock); tcf_exts_stats_update(flow->exts, nfp_flow->stats.bytes, nfp_flow->stats.pkts, nfp_flow->stats.used);