Skip to contentSkip to conversation

net: sched: get rid of cls_flower->egress_dev

PATCH Superseded Jiri Pirko 4 participants 22 messages Oct 10, 2017 – Oct 11, 2017 1 message not in the archive

Subsystems (5)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Jiri Pirko

author maintainer
#0 lore raw

cover net: sched: get rid of cls_flower->egress_dev

From: Jiri Pirko <[email protected]>

Introduction of cls_flower->egress_dev was a workaround. Turned out to be a bit ugly hack. So replace it with more generic and reusable infrastructure.

This is a dependency of shared block introduction that will be send as a follow-up patchsets group.

Jiri Pirko (4):
net: sched: make tc_action_ops->get_dev return dev and avoid passing
net
net: sched: introduce per-egress action device callbacks
net: sched: convert cls_flower->egress_dev users to tc_setup_cb_egdev
infra
net: sched: remove unused tcf_exts_get_dev helper and

    cls_flower->egress_dev
 drivers/net/ethernet/mellanox/mlx5/core/en.h      |   3 +
 drivers/net/ethernet/mellanox/mlx5/core/en_main.c |   4 +-
 drivers/net/ethernet/mellanox/mlx5/core/en_rep.c  |  31 ++--
 include/net/act_api.h                             |  37 +++-
 include/net/pkt_cls.h                             |   6 +-
 include/net/tc_act/tc_mirred.h                    |   1 +
 net/sched/act_api.c                               | 203 ++++++++++++++++++++++
 net/sched/act_mirred.c                            |  13 +-
 net/sched/cls_api.c                               |  35 ++--
 net/sched/cls_flower.c                            |  63 +++----
 10 files changed, 331 insertions(+), 65 deletions(-)
Signature · 1 line
2.9.5
author maintainer
#1 lore raw

PATCH 1/4 net: sched: make tc_action_ops->get_dev return dev and avoid passing net

From: Jiri Pirko <[email protected]>

Return dev directly, NULL if not possible. That is enough.

Makes no sense to pass struct net * to get_dev op, as there is only one net possible, the one the action was created in. So just store it in mirred priv and use directly.

Rename the mirred op callback function.

---
 include/net/act_api.h          |  3 +--
 include/net/tc_act/tc_mirred.h |  1 +
 net/sched/act_mirred.c         | 13 +++++--------
 net/sched/cls_api.c            |  6 ++----
 4 files changed, 9 insertions(+), 14 deletions(-)
include/net/act_api.h +1 -2
index b944e0e..900168a 100644
@@ -93,8 +93,7 @@ struct tc_action_ops {
 	int     (*walk)(struct net *, struct sk_buff *,
 			struct netlink_callback *, int, const struct tc_action_ops *);
 	void	(*stats_update)(struct tc_action *, u64, u32, u64);
-	int	(*get_dev)(const struct tc_action *a, struct net *net,
-			   struct net_device **mirred_dev);
+	struct net_device *(*get_dev)(const struct tc_action *a);
 };
 
 struct tc_action_net {
include/net/tc_act/tc_mirred.h +1 -0
index 604bc31..21a6565 100644
@@ -10,6 +10,7 @@ struct tcf_mirred {
 	int			tcfm_ifindex;
 	bool			tcfm_mac_header_xmit;
 	struct net_device __rcu	*tcfm_dev;
+	struct net		*net;
 	struct list_head	tcfm_list;
 };
 #define to_mirred(a) ((struct tcf_mirred *)a)
net/sched/act_mirred.c +5 -8
index 416627c..8b3e5938 100644
@@ -140,6 +140,7 @@ static int tcf_mirred_init(struct net *net, struct nlattr *nla,
 	m->tcfm_eaction = parm->eaction;
 	if (dev != NULL) {
 		m->tcfm_ifindex = parm->ifindex;
+		m->net = net;
 		if (ret != ACT_P_CREATED)
 			dev_put(rcu_dereference_protected(m->tcfm_dev, 1));
 		dev_hold(dev);
@@ -313,15 +314,11 @@ static struct notifier_block mirred_device_notifier = {
 	.notifier_call = mirred_device_event,
 };
 
-static int tcf_mirred_device(const struct tc_action *a, struct net *net,
-			     struct net_device **mirred_dev)
+static struct net_device *tcf_mirred_get_dev(const struct tc_action *a)
 {
-	int ifindex = tcf_mirred_ifindex(a);
+	struct tcf_mirred *m = to_mirred(a);
 
-	*mirred_dev = __dev_get_by_index(net, ifindex);
-	if (!*mirred_dev)
-		return -EINVAL;
-	return 0;
+	return __dev_get_by_index(m->net, m->tcfm_ifindex);
 }
 
 static struct tc_action_ops act_mirred_ops = {
@@ -336,7 +333,7 @@ static struct tc_action_ops act_mirred_ops = {
 	.walk		=	tcf_mirred_walker,
 	.lookup		=	tcf_mirred_search,
 	.size		=	sizeof(struct tcf_mirred),
-	.get_dev	=	tcf_mirred_device,
+	.get_dev	=	tcf_mirred_get_dev,
 };
 
 static __net_init int mirred_init_net(struct net *net)
net/sched/cls_api.c +2 -4
index 0b2219a..450873b 100644
@@ -1016,10 +1016,8 @@ int tcf_exts_get_dev(struct net_device *dev, struct tcf_exts *exts,
 
 	tcf_exts_to_list(exts, &actions);
 	list_for_each_entry(a, &actions, list) {
-		if (a->ops->get_dev) {
-			a->ops->get_dev(a, dev_net(dev), hw_dev);
-			break;
-		}
+		if (a->ops->get_dev)
+			*hw_dev = a->ops->get_dev(a);
 	}
 	if (*hw_dev)
 		return 0;
Signature · 1 line
2.9.5
author maintainer
#6 lore raw

PATCH 2/4 net: sched: introduce per-egress action device callbacks

In reply to Jiri Pirko

From: Jiri Pirko <[email protected]>

Introduce infrastructure that allows drivers to register callbacks that are called whenever tc would offload inserted rule and specified device acts as tc action egress device.

---
 include/net/act_api.h |  34 +++++++++
 include/net/pkt_cls.h |   2 +
 net/sched/act_api.c   | 203 ++++++++++++++++++++++++++++++++++++++++++++++++++
 net/sched/cls_api.c   |  30 ++++++++
 4 files changed, 269 insertions(+)
include/net/act_api.h +34 -0
index 900168a..f5e8c90 100644
@@ -174,4 +174,38 @@ static inline void tcf_action_stats_update(struct tc_action *a, u64 bytes,
 #endif
 }
 
+typedef int tc_setup_cb_t(enum tc_setup_type type,
+			  void *type_data, void *cb_priv);
+
+#ifdef CONFIG_NET_CLS_ACT
+int tc_setup_cb_egdev_register(const struct net_device *dev,
+			       tc_setup_cb_t *cb, void *cb_priv);
+void tc_setup_cb_egdev_unregister(const struct net_device *dev,
+				  tc_setup_cb_t *cb, void *cb_priv);
+int tc_setup_cb_egdev_call(const struct net_device *dev,
+			   enum tc_setup_type type, void *type_data,
+			   bool err_stop);
+#else
+static inline
+int tc_setup_cb_egdev_register(const struct net_device *dev,
+			       tc_setup_cb_t *cb, void *cb_priv)
+{
+	return 0;
+}
+
+static inline
+void tc_setup_cb_egdev_unregister(const struct net_device *dev,
+				  tc_setup_cb_t *cb, void *cb_priv)
+{
+}
+
+static inline
+int tc_setup_cb_egdev_call(const struct net_device *dev,
+			   enum tc_setup_type type, void *type_data,
+			   bool err_stop)
+{
+	return 0;
+}
+#endif
+
 #endif
include/net/pkt_cls.h +2 -0
index e80edd8..6f8149c 100644
@@ -206,6 +206,8 @@ int tcf_exts_dump(struct sk_buff *skb, struct tcf_exts *exts);
 int tcf_exts_dump_stats(struct sk_buff *skb, struct tcf_exts *exts);
 int tcf_exts_get_dev(struct net_device *dev, struct tcf_exts *exts,
 		     struct net_device **hw_dev);
+int tcf_exts_egdev_cb_call(struct tcf_exts *exts, enum tc_setup_type type,
+			   void *type_data, bool err_stop);
 
 /**
  * struct tcf_pkt_info - packet information
net/sched/act_api.c +203 -0

217 lines not on this page · raw message

net/sched/cls_api.c +30 -0
index 450873b..99f9432 100644
@@ -1026,6 +1026,36 @@ int tcf_exts_get_dev(struct net_device *dev, struct tcf_exts *exts,
 }
 EXPORT_SYMBOL(tcf_exts_get_dev);
 
+int tcf_exts_egdev_cb_call(struct tcf_exts *exts, enum tc_setup_type type,
+			   void *type_data, bool err_stop)
+{
+	int ok_count = 0;
+#ifdef CONFIG_NET_CLS_ACT
+	const struct tc_action *a;
+	struct net_device *dev;
+	LIST_HEAD(actions);
+	int ret;
+
+	if (!tcf_exts_has_actions(exts))
+		return 0;
+
+	tcf_exts_to_list(exts, &actions);
+	list_for_each_entry(a, &actions, list) {
+		if (!a->ops->get_dev)
+			continue;
+		dev = a->ops->get_dev(a);
+		if (!dev || !tc_can_offload(dev))
+			continue;
+		ret = tc_setup_cb_egdev_call(dev, type, type_data, err_stop);
+		if (ret < 0)
+			return ret;
+		ok_count += ret;
+	}
+#endif
+	return ok_count;
+}
+EXPORT_SYMBOL(tcf_exts_egdev_cb_call);
+
 static int __init tc_filter_init(void)
 {
 	rtnl_register(PF_UNSPEC, RTM_NEWTFILTER, tc_ctl_tfilter, NULL, 0);
Signature · 1 line
2.9.5
author maintainer
#11 lore raw

PATCH 3/4 net: sched: convert cls_flower->egress_dev users to tc_setup_cb_egdev infra

In reply to Jiri Pirko

From: Jiri Pirko <[email protected]>

The only user of cls_flower->egress_dev is mlx5. So do the conversion there alongside with the code originating the call in cls_flower function fl_hw_replace_filter to the newly introduced egress device callback infrastucture.

---
 drivers/net/ethernet/mellanox/mlx5/core/en.h      |  3 ++
 drivers/net/ethernet/mellanox/mlx5/core/en_main.c |  4 +-
 drivers/net/ethernet/mellanox/mlx5/core/en_rep.c  | 31 +++++++----
 include/net/pkt_cls.h                             |  5 +-
 net/sched/cls_api.c                               | 13 +++--
 net/sched/cls_flower.c                            | 63 ++++++++++++-----------
 6 files changed, 73 insertions(+), 46 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en.h +3 -0
index cc13d3d..5ec6d3e 100644
@@ -1081,6 +1081,9 @@ int mlx5e_ethtool_get_ts_info(struct mlx5e_priv *priv,
 int mlx5e_ethtool_flash_device(struct mlx5e_priv *priv,
 			       struct ethtool_flash *flash);
 
+int mlx5e_setup_tc(struct net_device *dev, enum tc_setup_type type,
+		   void *type_data);
+
 /* mlx5e generic netdev management API */
 struct net_device*
 mlx5e_create_netdev(struct mlx5_core_dev *mdev, const struct mlx5e_profile *profile,
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +2 -2
index cc11bbb..2a32102 100644
@@ -3108,8 +3108,8 @@ static int mlx5e_setup_tc_cls_flower(struct net_device *dev,
 }
 #endif
 
-static int mlx5e_setup_tc(struct net_device *dev, enum tc_setup_type type,
-			  void *type_data)
+int mlx5e_setup_tc(struct net_device *dev, enum tc_setup_type type,
+		   void *type_data)
 {
 	switch (type) {
 #ifdef CONFIG_MLX5_ESWITCH
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c +21 -10
index 45e03c4..765fc74 100644
@@ -34,6 +34,7 @@
 #include <linux/mlx5/fs.h>
 #include <net/switchdev.h>
 #include <net/pkt_cls.h>
+#include <net/act_api.h>
 #include <net/netevent.h>
 #include <net/arp.h>
 
@@ -667,14 +668,6 @@ mlx5e_rep_setup_tc_cls_flower(struct net_device *dev,
 	    cls_flower->common.chain_index)
 		return -EOPNOTSUPP;
 
-	if (cls_flower->egress_dev) {
-		struct mlx5_eswitch *esw = priv->mdev->priv.eswitch;
-
-		dev = mlx5_eswitch_get_uplink_netdev(esw);
-		return dev->netdev_ops->ndo_setup_tc(dev, TC_SETUP_CLSFLOWER,
-						     cls_flower);
-	}
-
 	switch (cls_flower->command) {
 	case TC_CLSFLOWER_REPLACE:
 		return mlx5e_configure_flower(priv, cls_flower);
@@ -698,6 +691,14 @@ static int mlx5e_rep_setup_tc(struct net_device *dev, enum tc_setup_type type,
 	}
 }
 
+static int mlx5e_rep_setup_tc_cb(enum tc_setup_type type, void *type_data,
+				 void *cb_priv)
+{
+	struct net_device *dev = cb_priv;
+
+	return mlx5e_setup_tc(dev, type, type_data);
+}
+
 bool mlx5e_is_uplink_rep(struct mlx5e_priv *priv)
 {
 	struct mlx5_eswitch *esw = priv->mdev->priv.eswitch;
@@ -1017,15 +1018,24 @@ mlx5e_vport_rep_load(struct mlx5_eswitch *esw, struct mlx5_eswitch_rep *rep)
 		goto err_detach_netdev;
 	}
 
+	err = tc_setup_cb_egdev_register(netdev, mlx5e_rep_setup_tc_cb,
+					 mlx5_eswitch_get_uplink_netdev(esw));
+	if (err)
+		goto err_neigh_cleanup;
+
 	err = register_netdev(netdev);
 	if (err) {
 		pr_warn("Failed to register representor netdev for vport %d\n",
 			rep->vport);
-		goto err_neigh_cleanup;
+		goto err_egdev_cleanup;
 	}
 
 	return 0;
 
+err_egdev_cleanup:
+	tc_setup_cb_egdev_unregister(netdev, mlx5e_rep_setup_tc_cb,
+				     mlx5_eswitch_get_uplink_netdev(esw));
+
 err_neigh_cleanup:
 	mlx5e_rep_neigh_cleanup(rpriv);
 
@@ -1047,7 +1057,8 @@ mlx5e_vport_rep_unload(struct mlx5_eswitch *esw, struct mlx5_eswitch_rep *rep)
 	void *ppriv = priv->ppriv;
 
 	unregister_netdev(rep->netdev);
-
+	tc_setup_cb_egdev_unregister(netdev, mlx5e_rep_setup_tc_cb,
+				     mlx5_eswitch_get_uplink_netdev(esw));
 	mlx5e_rep_neigh_cleanup(rpriv);
 	mlx5e_detach_netdev(priv);
 	mlx5e_destroy_netdev(priv);
include/net/pkt_cls.h +3 -2
index 6f8149c..c0bdf5c 100644
@@ -206,8 +206,6 @@ int tcf_exts_dump(struct sk_buff *skb, struct tcf_exts *exts);
 int tcf_exts_dump_stats(struct sk_buff *skb, struct tcf_exts *exts);
 int tcf_exts_get_dev(struct net_device *dev, struct tcf_exts *exts,
 		     struct net_device **hw_dev);
-int tcf_exts_egdev_cb_call(struct tcf_exts *exts, enum tc_setup_type type,
-			   void *type_data, bool err_stop);
 
 /**
  * struct tcf_pkt_info - packet information
@@ -407,6 +405,9 @@ tcf_match_indev(struct sk_buff *skb, int ifindex)
 }
 #endif /* CONFIG_NET_CLS_IND */
 
+int tc_setup_cb_call(struct tcf_exts *exts, enum tc_setup_type type,
+		     void *type_data, bool err_stop);
+
 struct tc_cls_common_offload {
 	u32 chain_index;
 	__be16 protocol;
net/sched/cls_api.c +10 -3
index 99f9432..51994a2 100644
@@ -1026,8 +1026,9 @@ int tcf_exts_get_dev(struct net_device *dev, struct tcf_exts *exts,
 }
 EXPORT_SYMBOL(tcf_exts_get_dev);
 
-int tcf_exts_egdev_cb_call(struct tcf_exts *exts, enum tc_setup_type type,
-			   void *type_data, bool err_stop)
+static int tc_exts_setup_cb_egdev_call(struct tcf_exts *exts,
+				       enum tc_setup_type type,
+				       void *type_data, bool err_stop)
 {
 	int ok_count = 0;
 #ifdef CONFIG_NET_CLS_ACT
@@ -1054,7 +1055,13 @@ int tcf_exts_egdev_cb_call(struct tcf_exts *exts, enum tc_setup_type type,
 #endif
 	return ok_count;
 }
-EXPORT_SYMBOL(tcf_exts_egdev_cb_call);
+
+int tc_setup_cb_call(struct tcf_exts *exts, enum tc_setup_type type,
+		     void *type_data, bool err_stop)
+{
+	return tc_exts_setup_cb_egdev_call(exts, type, type_data, err_stop);
+}
+EXPORT_SYMBOL(tc_setup_cb_call);
 
 static int __init tc_filter_init(void)
 {
net/sched/cls_flower.c +34 -29

108 lines not on this page · raw message

Signature · 1 line
2.9.5
author maintainer
#17 lore raw

PATCH 4/4 net: sched: remove unused tcf_exts_get_dev helper and cls_flower->egress_dev

In reply to Jiri Pirko

From: Jiri Pirko <[email protected]>

The helper and the struct field ares no longer used by any code, so remove them.

---
 include/net/pkt_cls.h |  3 ---
 net/sched/cls_api.c   | 22 ----------------------
 2 files changed, 25 deletions(-)
include/net/pkt_cls.h +0 -3
index c0bdf5c..f526374 100644
@@ -204,8 +204,6 @@ void tcf_exts_destroy(struct tcf_exts *exts);
 void tcf_exts_change(struct tcf_exts *dst, struct tcf_exts *src);
 int tcf_exts_dump(struct sk_buff *skb, struct tcf_exts *exts);
 int tcf_exts_dump_stats(struct sk_buff *skb, struct tcf_exts *exts);
-int tcf_exts_get_dev(struct net_device *dev, struct tcf_exts *exts,
-		     struct net_device **hw_dev);
 
 /**
  * struct tcf_pkt_info - packet information
@@ -517,7 +515,6 @@ struct tc_cls_flower_offload {
 	struct fl_flow_key *mask;
 	struct fl_flow_key *key;
 	struct tcf_exts *exts;
-	bool egress_dev;
 };
 
 enum tc_matchall_command {
net/sched/cls_api.c +0 -22
index 51994a2..2977b8a 100644
@@ -1004,28 +1004,6 @@ int tcf_exts_dump_stats(struct sk_buff *skb, struct tcf_exts *exts)
 }
 EXPORT_SYMBOL(tcf_exts_dump_stats);
 
-int tcf_exts_get_dev(struct net_device *dev, struct tcf_exts *exts,
-		     struct net_device **hw_dev)
-{
-#ifdef CONFIG_NET_CLS_ACT
-	const struct tc_action *a;
-	LIST_HEAD(actions);
-
-	if (!tcf_exts_has_actions(exts))
-		return -EINVAL;
-
-	tcf_exts_to_list(exts, &actions);
-	list_for_each_entry(a, &actions, list) {
-		if (a->ops->get_dev)
-			*hw_dev = a->ops->get_dev(a);
-	}
-	if (*hw_dev)
-		return 0;
-#endif
-	return -EOPNOTSUPP;
-}
-EXPORT_SYMBOL(tcf_exts_get_dev);
-
 static int tc_exts_setup_cb_egdev_call(struct tcf_exts *exts,
 				       enum tc_setup_type type,
 				       void *type_data, bool err_stop)
Signature · 1 line
2.9.5
#7 lore raw

RE: [patch net-next 2/4] net: sched: introduce per-egress action device callbacks

In reply to Jiri Pirko

From: Jiri Pirko

Quoted 4 lines

Sent: 10 October 2017 08:30
Introduce infrastructure that allows drivers to register callbacks that are called whenever tc would offload inserted rule and specified device acts as tc action egress device.

How does a driver safely unregister a callback?
(to avoid a race with the callback being called.)

Usually this requires a callback in the context that makes the notification callbacks indicating that no more such callbacks will be made.

David

author maintainer
#8 lore raw

Re: [patch net-next 2/4] net: sched: introduce per-egress action device callbacks

Quoted 6 lines · Tue, Oct 10, 2017 at 03:31:59PM CEST, [email protected] wrote:

From: Jiri Pirko

Quoted 4 lines

Sent: 10 October 2017 08:30
Introduce infrastructure that allows drivers to register callbacks that are called whenever tc would offload inserted rule and specified device acts as tc action egress device.

Quoted 6 lines

How does a driver safely unregister a callback?
(to avoid a race with the callback being called.)

Usually this requires a callback in the context that makes the notification callbacks indicating that no more such callbacks will be made.

rtnl is your answer. It is being held during register/unregister/cb

#9 lore raw

RE: [patch net-next 2/4] net: sched: introduce per-egress action device callbacks

From: Jiri Pirko

Quoted 13 lines

Sent: 10 October 2017 15:32
To: David Laight
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [patch net-next 2/4] net: sched: introduce per-egress action device callbacks

Quoted 6 lines · Tue, Oct 10, 2017 at 03:31:59PM CEST, [email protected] wrote:

From: Jiri Pirko

Quoted 4 lines

Sent: 10 October 2017 08:30
Introduce infrastructure that allows drivers to register callbacks that are called whenever tc would offload inserted rule and specified device acts as tc action egress device.

Quoted 8 lines
Quoted 6 lines

How does a driver safely unregister a callback?
(to avoid a race with the callback being called.)

Usually this requires a callback in the context that makes the notification callbacks indicating that no more such callbacks will be made.

rtnl is your answer. It is being held during register/unregister/cb

Do you mean 'acquired during register/unregister' and 'held across the callback' ?

So the unregister sleeps (or spins?) until any callbacks complete? So the driver mustn't hold any locks (etc) across the unregister that it acquires in the callback.
That ought to be noted somewhere.

David

author maintainer
#10 lore raw

Re: [patch net-next 2/4] net: sched: introduce per-egress action device callbacks

Quoted 23 lines · Tue, Oct 10, 2017 at 05:12:34PM CEST, [email protected] wrote:

From: Jiri Pirko

Quoted 13 lines

Sent: 10 October 2017 15:32
To: David Laight
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [patch net-next 2/4] net: sched: introduce per-egress action device callbacks

Quoted 6 lines · Tue, Oct 10, 2017 at 03:31:59PM CEST, [email protected] wrote:

From: Jiri Pirko

Quoted 4 lines

Sent: 10 October 2017 08:30
Introduce infrastructure that allows drivers to register callbacks that are called whenever tc would offload inserted rule and specified device acts as tc action egress device.

Quoted 8 lines
Quoted 6 lines

How does a driver safely unregister a callback?
(to avoid a race with the callback being called.)

Usually this requires a callback in the context that makes the notification callbacks indicating that no more such callbacks will be made.

rtnl is your answer. It is being held during register/unregister/cb

Quoted 7 lines

Do you mean 'acquired during register/unregister' and 'held across the callback' ?

So the unregister sleeps (or spins?) until any callbacks complete? So the driver mustn't hold any locks (etc) across the unregister that it acquires in the callback.
That ought to be noted somewhere.

You actually have a point. I don't take rtnl for reg/unreg as I suppose to. Will fix.

Quoted 3 lines

David

#18 lore raw
In reply to Jiri Pirko
Quoted 5 lines · Jiri Pirko

 drivers/net/ethernet/mellanox/mlx5/core/en.h      |   3 +
 drivers/net/ethernet/mellanox/mlx5/core/en_main.c |   4 +-
 drivers/net/ethernet/mellanox/mlx5/core/en_rep.c  |  31 ++--

Jiri,

FWIW, as I reported to you earlier, I was playing with tc encap/decap rules on 4.14-rc+ (net) before
applying any patch of this series, and something is messy w.r.t to decap rules. I don't see
them removed at all when user space attempts to do so. It might (probably) mlx5 bug, which
we will have to fix for net and later rebase net-next over net. We have short WW here so
I will not be able to do RCA this week.

#2 lore raw

Re: [patch net-next 1/4] net: sched: make tc_action_ops->get_dev return dev and avoid passing net

In reply to Jiri Pirko

net/sched/act_mirred.c static struct notifier_block mirred_device_notifier = { · line 321

Quoted 12 lines · Jiri Pirko
net/sched/act_mirred.c +3 -7
-static int tcf_mirred_device(const struct tc_action *a, struct net *net,
-                            struct net_device **mirred_dev)
+static struct net_device *tcf_mirred_get_dev(const struct tc_action *a)
 {
-       int ifindex = tcf_mirred_ifindex(a);
+       struct tcf_mirred *m = to_mirred(a);
 
-       *mirred_dev = __dev_get_by_index(net, ifindex);
-       if (!*mirred_dev)
-               return -EINVAL;
-       return 0;
+       return __dev_get_by_index(m->net, m->tcfm_ifindex);

Hmm, why not just return m->tcfm_dev?

#12 lore raw

Re: [patch net-next 3/4] net: sched: convert cls_flower->egress_dev users to tc_setup_cb_egdev infra

In reply to Jiri Pirko

include/net/pkt_cls.h int tcf_exts_dump(struct sk_buff *skb, struct tcf_exts *exts); · line 210

Quoted 8 lines · Jiri Pirko
include/net/pkt_cls.h +0 -2
@@ -206,8 +206,6 @@ int tcf_exts_dump(struct sk_buff *skb, struct tcf_exts *exts);
 int tcf_exts_dump_stats(struct sk_buff *skb, struct tcf_exts *exts);
 int tcf_exts_get_dev(struct net_device *dev, struct tcf_exts *exts,
                     struct net_device **hw_dev);
-int tcf_exts_egdev_cb_call(struct tcf_exts *exts, enum tc_setup_type type,
-                          void *type_data, bool err_stop);

but this (and another 1-2 hunks below) were set by upstream patch of this series, did you do that add/del on purpose? is that for bisection? if not why?

#13 lore raw

Re: [patch net-next 3/4] net: sched: convert cls_flower->egress_dev users to tc_setup_cb_egdev infra

In reply to Jiri Pirko
Quoted 1 line · Jiri Pirko

The only user of cls_flower->egress_dev is mlx5.

but nfp supports decap action offload too and from the flower code stand point, I guess they are both the same, right? how does it work there?

Or.

author maintainer
#20 lore raw
In reply to a message not in the archive
Quoted 11 lines · Tue, Oct 10, 2017 at 07:24:21PM CEST, [email protected] wrote:

Jiri,

FWIW, as I reported to you earlier, I was playing with tc encap/decap rules on 4.14-rc+ (net) before
applying any patch of this series, and something is messy w.r.t to decap rules. I don't see
them removed at all when user space attempts to do so. It might (probably) mlx5 bug, which
we will have to fix for net and later rebase net-next over net. We have short WW here so
I will not be able to do RCA this week.

Or, as I replied to you earlier, the issue you describe is totally unrelated to this patchset as you see the issue with the current net-next. Not sure why you add this comment here.

author maintainer
#14 lore raw

Re: [patch net-next 3/4] net: sched: convert cls_flower->egress_dev users to tc_setup_cb_egdev infra

In reply to Or Gerlitz
Quoted 6 lines · Tue, Oct 10, 2017 at 10:08:23PM CEST, [email protected] wrote:
Quoted 1 line · Jiri Pirko

The only user of cls_flower->egress_dev is mlx5.

but nfp supports decap action offload too and from the flower code stand point, I guess they are both the same, right? how does it work there?

Apparently they don't use cls_flower->egress_dev.

author maintainer
#3 lore raw

Re: [patch net-next 1/4] net: sched: make tc_action_ops->get_dev return dev and avoid passing net

In reply to Cong Wang
Quoted 8 lines · Tue, Oct 10, 2017 at 07:44:53PM CEST, [email protected] wrote:
Quoted 7 lines · Jiri Pirko
net/sched/act_mirred.c +2 -3
-static int tcf_mirred_device(const struct tc_action *a, struct net *net,
-                            struct net_device **mirred_dev)
+static struct net_device *tcf_mirred_get_dev(const struct tc_action *a)
 {
-       int ifindex = tcf_mirred_ifindex(a);
+       struct tcf_mirred *m = to_mirred(a);
Quoted 7 lines

net/sched/act_mirred.c static struct notifier_block mirred_device_notifier = { · line 321

Quoted 5 lines
net/sched/act_mirred.c +1 -4
-       *mirred_dev = __dev_get_by_index(net, ifindex);
-       if (!*mirred_dev)
-               return -EINVAL;
-       return 0;
+       return __dev_get_by_index(m->net, m->tcfm_ifindex);

Hmm, why not just return m->tcfm_dev?

I just follow the existing code. The change you suggest should be a separate follow-up patch.

#21 lore raw
In reply to Jiri Pirko
Quoted 4 lines · Jiri Pirko

Tue, Oct 10, 2017 at 07:24:21PM CEST, [email protected] wrote:

Or, as I replied to you earlier, the issue you describe is totally unrelated to this patchset as you see the issue with the current net-next.

Jiri, the point I wanted to make that if indeed there's a bug in mlx5 or flower, we will have to fix it for 4.14 and then these bits would have to be rebased when net-next is re-planted over net, I put "FWIW" before that, so maybe it doesn't W so much, we'll see.

Or.

#15 lore raw

Re: [patch net-next 3/4] net: sched: convert cls_flower->egress_dev users to tc_setup_cb_egdev infra

In reply to Jiri Pirko
Quoted 9 lines · Jiri Pirko
Quoted 6 lines · Tue, Oct 10, 2017 at 10:08:23PM CEST, [email protected] wrote:
Quoted 1 line · Jiri Pirko

The only user of cls_flower->egress_dev is mlx5.

but nfp supports decap action offload too and from the flower code stand point, I guess they are both the same, right? how does it work there?

Apparently they don't use cls_flower->egress_dev.

John, can you elaborate on that, how do you manage to get away from that practice?

author maintainer
#22 lore raw
In reply to Or Gerlitz
Quoted 10 lines · Tue, Oct 10, 2017 at 11:46:22PM CEST, [email protected] wrote:
Quoted 4 lines · Jiri Pirko

Tue, Oct 10, 2017 at 07:24:21PM CEST, [email protected] wrote:

Or, as I replied to you earlier, the issue you describe is totally unrelated to this patchset as you see the issue with the current net-next.

Jiri, the point I wanted to make that if indeed there's a bug in mlx5 or flower, we will have to fix it for 4.14 and then these bits would have to be rebased when net-next is re-planted over net, I put "FWIW" before that, so maybe it doesn't W so much, we'll see.

The fix is still unrelated to this patchset.

#16 lore raw

Re: [patch net-next 3/4] net: sched: convert cls_flower->egress_dev users to tc_setup_cb_egdev infra

In reply to Or Gerlitz
Quoted 5 lines · Or Gerlitz
Quoted 4 lines · Jiri Pirko
Quoted 3 lines · Tue, Oct 10, 2017 at 10:08:23PM CEST, [email protected] wrote:
Quoted 1 line · Jiri Pirko

The only user of cls_flower->egress_dev is mlx5.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

but nfp supports decap action offload too and from the flower code stand point, I guess they are both the same, right? how does it work there?

Apparently they don't use cls_flower->egress_dev.

John, can you elaborate on that, how do you manage to get away from that practice?

Looking on this a little more, it's clearly obvious that both fl_hw_update_stats and
fl_hw_destroy_filter never set egress_dev on the local variable which is set down
to the driver through the ndo.

For cases such as decap flow set on virtual SW tunnel device where f->hw_dev is the egress port, mlx5 fails to internally locate the driver rule object and we return -EINVAL
on both cases and hence deletion or stats will not take place.

I verified that in black box manner for both cases of deletion (the specific filer or the
whole ingress qdisc) and for the stats.

We have per ingress port rules table on the driver and maybe nfp doesn't and hence
why they didn't fell on that, not sure, I copied the folks here.

Commit a6e1693129 "net/sched: cls_flower: Set the filter Hardware device for all use-cases"
tries to fix something and does mention the stats and destroy cases, but I don't see how
it helps for that :(

I will keep looking next week (starting holiday here now) and try to get a fix for net and stable.

Or.

#4 lore raw

Re: [patch net-next 1/4] net: sched: make tc_action_ops->get_dev return dev and avoid passing net

In reply to Jiri Pirko
Quoted 17 lines · Jiri Pirko
Quoted 8 lines · Tue, Oct 10, 2017 at 07:44:53PM CEST, [email protected] wrote:
Quoted 7 lines · Jiri Pirko
net/sched/act_mirred.c +2 -3
-static int tcf_mirred_device(const struct tc_action *a, struct net *net,
-                            struct net_device **mirred_dev)
+static struct net_device *tcf_mirred_get_dev(const struct tc_action *a)
 {
-       int ifindex = tcf_mirred_ifindex(a);
+       struct tcf_mirred *m = to_mirred(a);
Quoted 7 lines

net/sched/act_mirred.c static struct notifier_block mirred_device_notifier = { · line 321

Quoted 5 lines
net/sched/act_mirred.c +1 -4
-       *mirred_dev = __dev_get_by_index(net, ifindex);
-       if (!*mirred_dev)
-               return -EINVAL;
-       return 0;
+       return __dev_get_by_index(m->net, m->tcfm_ifindex);

Hmm, why not just return m->tcfm_dev?

Quoted 2 lines

I just follow the existing code. The change you suggest should be a separate follow-up patch.

Why?

Your goal is "make tc_action_ops->get_dev return dev and avoid passing net", using m->tcfm_dev is simpler and could save you from adding a net pointer to struct tcf_mirred too.

author maintainer
#5 lore raw

Re: [patch net-next 1/4] net: sched: make tc_action_ops->get_dev return dev and avoid passing net

Quoted 18 lines · Wed, Oct 11, 2017 at 06:34:51PM CEST, [email protected] wrote:
Quoted 17 lines · Jiri Pirko
Quoted 15 lines · Tue, Oct 10, 2017 at 07:44:53PM CEST, [email protected] wrote:

net/sched/act_mirred.c static struct notifier_block mirred_device_notifier = { · line 321

Quoted 12 lines · Jiri Pirko
net/sched/act_mirred.c +3 -7
-static int tcf_mirred_device(const struct tc_action *a, struct net *net,
-                            struct net_device **mirred_dev)
+static struct net_device *tcf_mirred_get_dev(const struct tc_action *a)
 {
-       int ifindex = tcf_mirred_ifindex(a);
+       struct tcf_mirred *m = to_mirred(a);
 
-       *mirred_dev = __dev_get_by_index(net, ifindex);
-       if (!*mirred_dev)
-               return -EINVAL;
-       return 0;
+       return __dev_get_by_index(m->net, m->tcfm_ifindex);

Hmm, why not just return m->tcfm_dev?

Quoted 4 lines
Quoted 2 lines

I just follow the existing code. The change you suggest should be a separate follow-up patch.

Why?

I try to do small contained changes per patch. The resulting code is doing the same thing as the original, therefore reducing possible bug appearance.

Quoted 4 lines

Your goal is "make tc_action_ops->get_dev return dev and avoid passing net", using m->tcfm_dev is simpler and could save you from adding a net pointer to struct tcf_mirred too.