fib offload: switch to notifier
Subsystems (7)
Jiri Pirko
maintainerv3 cover fib offload: switch to notifier
From: Jiri Pirko <[email protected]>
The goal of this patchset is to allow driver to propagate all prefixes configured in kernel down HW. This is necessary for routing to work as expected. If we don't do that HW might forward prefixes known to kernel incorrectly. Take an example when default route is set in switch HW and there is an IP address set on a management (non-switch) port.
Currently, only FIB entries related to the switch port netdev are offloaded using switchdev ops. This model is not extendable so the first patch introduces a replacement: notifier to propagate FIB entry additions and removals to whoever is interested.
The second patch introduces couple of helpers to deal with RTNH_F_OFFLOAD flags. Currently it is set in switchdev core. There the assumption is that only one offload device exists. But for FIB notifier, we assume multiple offload devices. So the patch introduces a per FIB entry reference counter and helpers use it in order to achieve this:
0 means RTNH_F_OFFLOAD is not set, no device offloads this entry n means RTNH_F_OFFLOAD is set and the entry is offloaded by n devices
Patches 3 and 4 convert mlxsw and rocker to adopt this new way, registering one notifier block for each asic instance. Both of these patches also implement internal "abort" mechanism.
Using switchdev ops, "abort" is called by switchdev core whenever there is an error during FIB entry add offload. This leads to removal of all offloaded entries on system by fib_trie code.
Now the new notifier assumes the driver takes care of the abort action. Here's why:
1) The fact that one HW cannot offload an entry does not mean that the others can't do it. So let only one entity to abort and leave the rest to work happily.
2) The driver knows what to in order to properly abort. For example, currently abort is broken for mlxsw, as for Spectrum there is a need to set 0.0.0.0/0 trap in RALUE register.
The fifth patch removes the old, no longer used FIB offload infrastructure.
The last patch reflects the changes into switchdev documentation file.
---v2->v3:
-patch 3/6
-fixed offload inc/dec to be done in fib4_entry_init/fini and only
in case !trap as suggested by Idov1->v2:
-patch 3/6:
-fixed lpm tree setup and binding for abort and pointed out by Ido -do nexthop checks as suggested by Ido
-fix use after free during abort
-patch 6/6:
-fixed texts as suggested by Ido
Jiri Pirko (6):
fib: introduce FIB notification infrastructure
fib: introduce FIB info offload flag helpers
mlxsw: spectrum_router: Use FIB notifications instead of switchdev
calls
rocker: use FIB notifications instead of switchdev calls
switchdev: remove FIB offload infrastructure
doc: update switchdev L3 section
Documentation/networking/switchdev.txt | 27 +- drivers/net/ethernet/mellanox/mlxsw/spectrum.h | 9 +- .../net/ethernet/mellanox/mlxsw/spectrum_router.c | 437 ++++++++++++--------- .../ethernet/mellanox/mlxsw/spectrum_switchdev.c | 9 - drivers/net/ethernet/rocker/rocker.h | 15 +- drivers/net/ethernet/rocker/rocker_main.c | 120 ++++-- drivers/net/ethernet/rocker/rocker_ofdpa.c | 115 ++++-- include/net/ip_fib.h | 49 ++- include/net/switchdev.h | 40 -- net/ipv4/fib_frontend.c | 29 +- net/ipv4/fib_rules.c | 12 +- net/ipv4/fib_trie.c | 166 +++----- net/switchdev/switchdev.c | 181 --------- 13 files changed, 581 insertions(+), 628 deletions(-)
Signature · 1 line
2.5.5
Jiri Pirko
maintainerPATCH v3 1/6 fib: introduce FIB notification infrastructure
From: Jiri Pirko <[email protected]>
This allows to pass information about added/deleted FIB entries/rules to whoever is interested. This is done in a very similar way as devinet notifies address additions/removals.
--- include/net/ip_fib.h | 34 ++++++++++++++++++++++++--- net/ipv4/fib_frontend.c | 16 ++++++------- net/ipv4/fib_rules.c | 10 ++++++++ net/ipv4/fib_trie.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++--- 4 files changed, 108 insertions(+), 14 deletions(-)
include/net/ip_fib.h +31 -3
@@ -22,6 +22,7 @@#include <net/fib_rules.h> #include <net/inetpeer.h> #include <linux/percpu.h> +#include <linux/notifier.h> struct fib_config {u8 fc_dst_len;
@@ -185,6 +186,33 @@ __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh);#define FIB_RES_PREFSRC (net, res) ((res).fi->fib_prefsrc ? : \ FIB_RES_SADDR(net, res)) +struct fib_notifier_info { +struct net *net; +}; + +struct fib_entry_notifier_info { +struct fib_notifier_info info;/* must be first */ +u32 dst; +int dst_len; +struct fib_info *fi; +u8 tos; +u8 type; +u32 tb_id; +u32 nlflags; +}; + +enum fib_event_type { +FIB_EVENT_ENTRY_ADD , +FIB_EVENT_ENTRY_DEL , +FIB_EVENT_RULE_ADD , +FIB_EVENT_RULE_DEL , +}; + +int register_fib_notifier (struct notifier_block *nb); +int unregister_fib_notifier (struct notifier_block *nb); +int call_fib_notifiers (struct net *net,enum fib_event_type event_type, +struct fib_notifier_info *info); +struct fib_table {struct hlist_node tb_hlist;u32 tb_id;
@@ -196,11 +224,11 @@ struct fib_table {int fib_table_lookup (struct fib_table *tb,const struct flowi4 *flp,struct fib_result *res,int fib_flags); -int fib_table_insert (struct fib_table *,struct fib_config *); -int fib_table_delete (struct fib_table *,struct fib_config *); +int fib_table_insert (struct net *,struct fib_table *,struct fib_config *); +int fib_table_delete (struct net *,struct fib_table *,struct fib_config *);int fib_table_dump (struct fib_table *table,struct sk_buff *skb,struct netlink_callback *cb); -int fib_table_flush (struct fib_table *table); +int fib_table_flush (struct net *net,struct fib_table *table);struct fib_table *fib_trie_unmerge (struct fib_table *main_tb);void fib_table_flush_external (struct fib_table *table);void fib_free_table (struct fib_table *tb);
net/ipv4/fib_frontend.c +8 -8
@@ -182,7 +182,7 @@ static void fib_flush(struct net *net)struct fib_table *tb;hlist_for_each_entry_safe (tb, tmp, head, tb_hlist) - flushed +=fib_table_flush (tb); + flushed +=fib_table_flush (net, tb); }if (flushed)
@@ -590,13 +590,13 @@ int ip_rt_ioctl(struct net *net, unsigned int cmd, void __user *arg)if (cmd ==SIOCDELRT ) { tb =fib_get_table (net, cfg.fc_table);if (tb) - err =fib_table_delete (tb, &cfg); + err =fib_table_delete (net, tb, &cfg);else err = -ESRCH ; }else { tb =fib_new_table (net, cfg.fc_table);if (tb) - err =fib_table_insert (tb, &cfg); + err =fib_table_insert (net, tb, &cfg);else err = -ENOBUFS ; }
@@ -719,7 +719,7 @@ static int inet_rtm_delroute(struct sk_buff *skb, struct nlmsghdr *nlh) goto errout; } - err =fib_table_delete (tb, &cfg); + err =fib_table_delete (net, tb, &cfg); errout:return err; }
@@ -741,7 +741,7 @@ static int inet_rtm_newroute(struct sk_buff *skb, struct nlmsghdr *nlh) goto errout; } - err =fib_table_insert (tb, &cfg); + err =fib_table_insert (net, tb, &cfg); errout:return err; }
@@ -828,9 +828,9 @@ static void fib_magic(int cmd, int type, __be32 dst, int dst_len, struct in_ifad cfg.fc_scope =RT_SCOPE_HOST ;if (cmd ==RTM_NEWROUTE ) -fib_table_insert (tb, &cfg); +fib_table_insert (net, tb, &cfg);else -fib_table_delete (tb, &cfg); +fib_table_delete (net, tb, &cfg); }void fib_add_ifaddr (struct in_ifaddr *ifa)
@@ -1254,7 +1254,7 @@ static void ip_fib_net_exit(struct net *net)hlist_for_each_entry_safe (tb, tmp, head, tb_hlist) {hlist_del (&tb->tb_hlist); -fib_table_flush (tb); +fib_table_flush (net, tb);fib_free_table (tb); } }
net/ipv4/fib_rules.c +10 -0
@@ -164,6 +164,14 @@ static struct fib_table *fib_empty_table(struct net *net)return NULL ; } +static int call_fib_rule_notifiers (struct net *net, +enum fib_event_type event_type) +{ +struct fib_notifier_info info; + +return call_fib_notifiers (net, event_type, &info); +} +static const struct nla_policy fib4_rule_policy[FRA_MAX +1 ] = {FRA_GENERIC_POLICY , [FRA_FLOW ] = { .type =NLA_U32 },
@@ -221,6 +229,7 @@ static int fib4_rule_configure(struct fib_rule *rule, struct sk_buff *skb, net->ipv4.fib_has_custom_rules = true;fib_flush_external (rule->fr_net); +call_fib_rule_notifiers (net,FIB_EVENT_RULE_ADD ); err =0 ; errout:
@@ -243,6 +252,7 @@ static int fib4_rule_delete(struct fib_rule *rule)#endif net->ipv4.fib_has_custom_rules = true;fib_flush_external (rule->fr_net); +call_fib_rule_notifiers (net,FIB_EVENT_RULE_DEL ); errout:return err; }
net/ipv4/fib_trie.c +59 -3
116 lines not on this page · raw message
Signature · 1 line
2.5.5
Jiri Pirko
maintainerPATCH v3 2/6 fib: introduce FIB info offload flag helpers
In reply to Jiri PirkoFrom: Jiri Pirko <[email protected]>
These helpers are to be used in case someone offloads the FIB entry. The result is that if the entry is offloaded to at least one device, the offload flag is set.
--- include/net/ip_fib.h | 13 +++++++++++++ net/switchdev/switchdev.c | 4 ++-- 2 files changed, 15 insertions(+), 2 deletions(-)
include/net/ip_fib.h +13 -0
@@ -123,6 +123,7 @@ struct fib_info {#ifdef CONFIG_IP_ROUTE_MULTIPATH int fib_weight;#endif +unsigned int fib_offload_cnt;struct rcu_head rcu;struct fib_nh fib_nh[0 ];#define fib_dev fib_nh[0].nh_dev
@@ -174,6 +175,18 @@ struct fib_result_nl {__be32 fib_info_update_nh_saddr (struct net *net,struct fib_nh *nh); +static inline void fib_info_offload_inc (struct fib_info *fi) +{ + fi->fib_offload_cnt++; + fi->fib_flags |=RTNH_F_OFFLOAD ; +} + +static inline void fib_info_offload_dec (struct fib_info *fi) +{ +if (--fi->fib_offload_cnt ==0 ) + fi->fib_flags &= ~RTNH_F_OFFLOAD ; +} +#define FIB_RES_SADDR (net, res) \ ((FIB_RES_NH(res).nh_saddr_genid == \ atomic_read(&(net)->ipv4.dev_addr_genid)) ? \
net/switchdev/switchdev.c +2 -2
@@ -1216,7 +1216,7 @@ int switchdev_fib_ipv4_add(u32 dst, int dst_len, struct fib_info *fi, ipv4_fib.obj.orig_dev = dev; err =switchdev_port_obj_add (dev, &ipv4_fib.obj);if (!err) - fi->fib_flags |=RTNH_F_OFFLOAD ; +fib_info_offload_inc (fi);return err == -EOPNOTSUPP ?0 : err; }
@@ -1260,7 +1260,7 @@ int switchdev_fib_ipv4_del(u32 dst, int dst_len, struct fib_info *fi, ipv4_fib.obj.orig_dev = dev; err =switchdev_port_obj_del (dev, &ipv4_fib.obj);if (!err) - fi->fib_flags &= ~RTNH_F_OFFLOAD ; +fib_info_offload_dec (fi);return err == -EOPNOTSUPP ?0 : err; }
Signature · 1 line
2.5.5
Jiri Pirko
maintainerPATCH v3 3/6 mlxsw: spectrum_router: Use FIB notifications instead of switchdev calls
In reply to Jiri PirkoFrom: Jiri Pirko <[email protected]>
Until now, in order to offload a FIB entry to HW we use switchdev op. However that has limits. Mainly in case we need to make the HW aware of all route prefixes configured in kernel. HW needs to know those in order to properly trap appropriate packets and pass the to kernel to do the forwarding. Abort mechanism is now handled within the mlxsw driver.
--- drivers/net/ethernet/mellanox/mlxsw/spectrum.h | 9 +- .../net/ethernet/mellanox/mlxsw/spectrum_router.c | 437 ++++++++++++--------- .../ethernet/mellanox/mlxsw/spectrum_switchdev.c | 9 - 3 files changed, 260 insertions(+), 195 deletions(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum.h +3 -6
@@ -45,7 +45,7 @@#include <linux/list.h> #include <linux/dcbnl.h> #include <linux/in6.h> -#include <net/switchdev.h> +#include <linux/notifier.h> #include "port.h" #include "core.h"
@@ -257,6 +257,7 @@ struct mlxsw_sp_router {#define MLXSW_SP_UNRESOLVED_NH_PROBE_INTERVAL 5000/* ms */ struct list_head nexthop_group_list;struct list_head nexthop_neighs_list; +bool aborted; };struct mlxsw_sp {
@@ -296,6 +297,7 @@ struct mlxsw_sp {struct mlxsw_sp_span_entry *entries;int entries_count; } span; +struct notifier_block fib_nb; }; static inline struct mlxsw_sp_upper *
@@ -584,11 +586,6 @@ static inline void mlxsw_sp_port_dcb_fini(struct mlxsw_sp_port *mlxsw_sp_port)int mlxsw_sp_router_init (struct mlxsw_sp *mlxsw_sp);void mlxsw_sp_router_fini (struct mlxsw_sp *mlxsw_sp); -int mlxsw_sp_router_fib4_add (struct mlxsw_sp_port *mlxsw_sp_port, -const struct switchdev_obj_ipv4_fib *fib4, -struct switchdev_trans *trans); -int mlxsw_sp_router_fib4_del (struct mlxsw_sp_port *mlxsw_sp_port, -const struct switchdev_obj_ipv4_fib *fib4);int mlxsw_sp_router_neigh_construct (struct net_device *dev,struct neighbour *n); void mlxsw_sp_router_neigh_destroy(struct net_device *dev,
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c +257 -180
581 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c +0 -9
@@ -1044,11 +1044,6 @@ static int mlxsw_sp_port_obj_add(struct net_device *dev,SWITCHDEV_OBJ_PORT_VLAN (obj), trans);break ; -case SWITCHDEV_OBJ_ID_IPV4_FIB : - err =mlxsw_sp_router_fib4_add (mlxsw_sp_port, -SWITCHDEV_OBJ_IPV4_FIB (obj), - trans); -break ;case SWITCHDEV_OBJ_ID_PORT_FDB : err = mlxsw_sp_port_fdb_static_add(mlxsw_sp_port, SWITCHDEV_OBJ_PORT_FDB(obj),
@@ -1181,10 +1176,6 @@ static int mlxsw_sp_port_obj_del(struct net_device *dev, err =mlxsw_sp_port_vlans_del (mlxsw_sp_port,SWITCHDEV_OBJ_PORT_VLAN (obj));break ; -case SWITCHDEV_OBJ_ID_IPV4_FIB : - err =mlxsw_sp_router_fib4_del (mlxsw_sp_port, -SWITCHDEV_OBJ_IPV4_FIB (obj)); -break ;case SWITCHDEV_OBJ_ID_PORT_FDB : err =mlxsw_sp_port_fdb_static_del (mlxsw_sp_port,SWITCHDEV_OBJ_PORT_FDB (obj));
Signature · 1 line
2.5.5
Jiri Pirko
maintainerPATCH v3 4/6 rocker: use FIB notifications instead of switchdev calls
In reply to Jiri PirkoFrom: Jiri Pirko <[email protected]>
Until now, in order to offload a FIB entry to HW we use switchdev op. Use the newly introduced FIB notifier infrasturucture to process FIB entries to offload the in HW.
Abort mechanism is now handled within the rocker driver.
--- drivers/net/ethernet/rocker/rocker.h | 15 ++-- drivers/net/ethernet/rocker/rocker_main.c | 120 +++++++++++++++++++++-------- drivers/net/ethernet/rocker/rocker_ofdpa.c | 115 ++++++++++++++++++++------- 3 files changed, 185 insertions(+), 65 deletions(-)
drivers/net/ethernet/rocker/rocker.h +10 -5
@@ -15,6 +15,7 @@#include <linux/kernel.h> #include <linux/types.h> #include <linux/netdevice.h> +#include <linux/notifier.h> #include <net/neighbour.h> #include <net/switchdev.h>
@@ -52,6 +53,9 @@ struct rocker_port {struct rocker_dma_ring_info rx_ring; }; +struct rocker_port *rocker_port_dev_lower_find (struct net_device *dev, +struct rocker *rocker); +struct rocker_world_ops ;struct rocker {
@@ -66,6 +70,7 @@ struct rocker {spinlock_t cmd_ring_lock;/* for cmd ring accesses */ struct rocker_dma_ring_info cmd_ring;struct rocker_dma_ring_info event_ring; +struct notifier_block fib_nb;struct rocker_world_ops *wops;void *wpriv; };
@@ -117,11 +122,6 @@ struct rocker_world_ops {int (*port_obj_vlan_dump)(const struct rocker_port *rocker_port,struct switchdev_obj_port_vlan *vlan,switchdev_obj_dump_cb_t *cb); -int (*port_obj_fib4_add)(struct rocker_port *rocker_port, -const struct switchdev_obj_ipv4_fib *fib4, -struct switchdev_trans *trans); -int (*port_obj_fib4_del)(struct rocker_port *rocker_port, -const struct switchdev_obj_ipv4_fib *fib4);int (*port_obj_fdb_add)(struct rocker_port *rocker_port,const struct switchdev_obj_port_fdb *fdb,struct switchdev_trans *trans);
@@ -141,6 +141,11 @@ struct rocker_world_ops {int (*port_ev_mac_vlan_seen)(struct rocker_port *rocker_port,const unsigned char *addr,__be16 vlan_id); +int (*fib4_add)(struct rocker *rocker, +const struct fib_entry_notifier_info *fen_info); +int (*fib4_del)(struct rocker *rocker, +const struct fib_entry_notifier_info *fen_info); +void (*fib4_abort)(struct rocker *rocker); };extern struct rocker_world_ops rocker_ofdpa_ops;
drivers/net/ethernet/rocker/rocker_main.c +88 -32
168 lines not on this page · raw message
drivers/net/ethernet/rocker/rocker_ofdpa.c +87 -28
179 lines not on this page · raw message
Signature · 1 line
2.5.5
Jiri Pirko
maintainerPATCH v3 5/6 switchdev: remove FIB offload infrastructure
In reply to Jiri PirkoFrom: Jiri Pirko <[email protected]>
Since this is now taken care of by FIB notifier, remove the code, with all unused dependencies.
--- include/net/ip_fib.h | 2 - include/net/switchdev.h | 40 ---------- net/ipv4/fib_frontend.c | 13 ---- net/ipv4/fib_rules.c | 2 - net/ipv4/fib_trie.c | 104 +------------------------- net/switchdev/switchdev.c | 181 ---------------------------------------------- 6 files changed, 1 insertion(+), 341 deletions(-)
include/net/ip_fib.h +0 -2
@@ -243,7 +243,6 @@ int fib_table_dump(struct fib_table *table, struct sk_buff *skb, struct netlink_callback *cb);int fib_table_flush (struct net *net,struct fib_table *table);struct fib_table *fib_trie_unmerge (struct fib_table *main_tb); -void fib_table_flush_external (struct fib_table *table);void fib_free_table (struct fib_table *tb);#ifndef CONFIG_IP_MULTIPLE_TABLES
@@ -356,7 +355,6 @@ static inline int fib_num_tclassid_users(struct net *net) }#endif int fib_unmerge (struct net *net); -void fib_flush_external (struct net *net);/* Exported by fib_semantics.c */ int ip_fib_check_default (__be32 gw,struct net_device *dev);
include/net/switchdev.h +0 -40
@@ -68,7 +68,6 @@ struct switchdev_attr {enum switchdev_obj_id {SWITCHDEV_OBJ_ID_UNDEFINED ,SWITCHDEV_OBJ_ID_PORT_VLAN , -SWITCHDEV_OBJ_ID_IPV4_FIB ,SWITCHDEV_OBJ_ID_PORT_FDB ,SWITCHDEV_OBJ_ID_PORT_MDB , };
@@ -92,21 +91,6 @@ struct switchdev_obj_port_vlan {#define SWITCHDEV_OBJ_PORT_VLAN (obj) \ container_of(obj, struct switchdev_obj_port_vlan, obj) -/* SWITCHDEV_OBJ_ID_IPV4_FIB */ -struct switchdev_obj_ipv4_fib { -struct switchdev_obj obj; -u32 dst; -int dst_len; -struct fib_info *fi; -u8 tos; -u8 type; -u32 nlflags; -u32 tb_id; -}; - -#define SWITCHDEV_OBJ_IPV4_FIB (obj) \ - container_of(obj, struct switchdev_obj_ipv4_fib, obj) -/* SWITCHDEV_OBJ_ID_PORT_FDB */ struct switchdev_obj_port_fdb {struct switchdev_obj obj;
@@ -209,11 +193,6 @@ int switchdev_port_bridge_setlink(struct net_device *dev, struct nlmsghdr *nlh, u16 flags);int switchdev_port_bridge_dellink (struct net_device *dev,struct nlmsghdr *nlh,u16 flags); -int switchdev_fib_ipv4_add (u32 dst,int dst_len,struct fib_info *fi, -u8 tos,u8 type,u32 nlflags,u32 tb_id); -int switchdev_fib_ipv4_del (u32 dst,int dst_len,struct fib_info *fi, -u8 tos,u8 type,u32 tb_id); -void switchdev_fib_ipv4_abort (struct fib_info *fi);int switchdev_port_fdb_add (struct ndmsg *ndm,struct nlattr *tb[],struct net_device *dev,const unsigned char *addr,u16 vid,u16 nlm_flags);
@@ -304,25 +283,6 @@ static inline int switchdev_port_bridge_dellink(struct net_device *dev,return -EOPNOTSUPP ; } -static inline int switchdev_fib_ipv4_add (u32 dst,int dst_len, -struct fib_info *fi, -u8 tos,u8 type, -u32 nlflags,u32 tb_id) -{ -return 0 ; -} - -static inline int switchdev_fib_ipv4_del (u32 dst,int dst_len, -struct fib_info *fi, -u8 tos,u8 type,u32 tb_id) -{ -return 0 ; -} - -static inline void switchdev_fib_ipv4_abort (struct fib_info *fi) -{ -} - static inline int switchdev_port_fdb_add(struct ndmsg *ndm, struct nlattr *tb[], struct net_device *dev, const unsigned char *addr,
net/ipv4/fib_frontend.c +0 -13
@@ -189,19 +189,6 @@ static void fib_flush(struct net *net)rt_cache_flush (net); } -void fib_flush_external (struct net *net) -{ -struct fib_table *tb; -struct hlist_head *head; -unsigned int h; - -for (h =0 ; h <FIB_TABLE_HASHSZ ; h++) { - head = &net->ipv4.fib_table_hash[h]; -hlist_for_each_entry (tb, head, tb_hlist) -fib_table_flush_external (tb); - } -} -/* * Find address type as if only "dev" was present in the system. If * on_dev is NULL then all interfaces are taken into consideration.
net/ipv4/fib_rules.c +0 -2
@@ -228,7 +228,6 @@ static int fib4_rule_configure(struct fib_rule *rule, struct sk_buff *skb, rule4->tos = frh->tos; net->ipv4.fib_has_custom_rules = true; -fib_flush_external (rule->fr_net);call_fib_rule_notifiers (net,FIB_EVENT_RULE_ADD ); err =0 ;
@@ -251,7 +250,6 @@ static int fib4_rule_delete(struct fib_rule *rule) net->ipv4.fib_num_tclassid_users--;#endif net->ipv4.fib_has_custom_rules = true; -fib_flush_external (rule->fr_net);call_fib_rule_notifiers (net,FIB_EVENT_RULE_DEL ); errout:return err;
net/ipv4/fib_trie.c +1 -103
149 lines not on this page · raw message
net/switchdev/switchdev.c +0 -181
199 lines not on this page · raw message
Signature · 1 line
2.5.5
Jiri Pirko
maintainerPATCH v3 6/6 doc: update switchdev L3 section
In reply to Jiri PirkoFrom: Jiri Pirko <[email protected]>
This is to reflect the change of FIB offload infrastructure from switchdev objects to FIB notifier.
--- Documentation/networking/switchdev.txt | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-)
Documentation/networking/switchdev.txt +14 -13
@@ -314,30 +314,29 @@ the kernel, with the device doing the FIB lookup and forwarding. The device does a longest prefix match (LPM) on FIB entries matching route prefix and forwards the packet to the matching FIB entry's nexthop(s) egress ports. -To program the device, the driver implements support for -SWITCHDEV_OBJ_IPV[4|6]_FIB object using switchdev_port_obj_xxx ops. -switchdev_port_obj_add is used for both adding a new FIB entry to the device, -or modifying an existing entry on the device. +To program the device, the driver has to register a FIB notifier handler +using register_fib_notifier. The following events are available: +FIB_EVENT_ENTRY_ADD: used for both adding a new FIB entry to the device, + or modifying an existing entry on the device. +FIB_EVENT_ENTRY_DEL: used for removing a FIB entry +FIB_EVENT_RULE_ADD, FIB_EVENT_RULE_DEL: used to propagate FIB rule changes -XXX: Currently, only SWITCHDEV_OBJ_ID_IPV4_FIB objects are supported. +FIB_EVENT_ENTRY_ADD and FIB_EVENT_ENTRY_DEL events pass: -SWITCHDEV_OBJ_ID_IPV4_FIB object passes: - - struct switchdev_obj_ipv4_fib { /* IPV4_FIB */ + struct fib_entry_notifier_info { + struct fib_notifier_info info; /* must be first */ u32 dst; int dst_len; struct fib_info *fi; u8 tos; u8 type; - u32 nlflags; u32 tb_id; - } ipv4_fib; + u32 nlflags; + }; to add/modify/delete IPv4 dst/dest_len prefix on table tb_id. The *fi structure holds details on the route and route's nexthops. *dev is one of the -port netdevs mentioned in the routes next hop list. If the output port netdevs -referenced in the route's nexthop list don't all have the same switch ID, the -driver is not called to add/modify/delete the FIB entry. +port netdevs mentioned in the route's next hop list. Routes offloaded to the device are labeled with "offload" in the ip route listing:
@@ -355,6 +354,8 @@ listing: 12.0.0.4 via 11.0.0.9 dev sw1p2 proto zebra metric 20 offload 192.168.0.0/24 dev eth0 proto kernel scope link src 192.168.0.15 +The "offload" flag is set in case at least one device offloads the FIB entry. + XXX: add/mod/del IPv6 FIB API Nexthop Resolution
Signature · 1 line
2.5.5
Re: [patch net-next v3 3/6] mlxsw: spectrum_router: Use FIB notifications instead of switchdev calls
In reply to Jiri PirkoQuoted 9 lines · Jiri Pirko
From: Jiri Pirko <[email protected]>
Until now, in order to offload a FIB entry to HW we use switchdev op. However that has limits. Mainly in case we need to make the HW aware of all route prefixes configured in kernel. HW needs to know those in order to properly trap appropriate packets and pass the to kernel to do the forwarding. Abort mechanism is now handled within the mlxsw driver.
Signed-off-by Jiri Pirko <[email protected]>
Thanks
David Miller
maintainerFrom: Jiri Pirko <[email protected]>
Date: Mon, 26 Sep 2016 12:52:28 +0200
Quoted 10 lines
The goal of this patchset is to allow driver to propagate all prefixes configured in kernel down HW. This is necessary for routing to work as expected. If we don't do that HW might forward prefixes known to kernel incorrectly. Take an example when default route is set in switch HW and there is an IP address set on a management (non-switch) port.
Currently, only FIB entries related to the switch port netdev are offloaded using switchdev ops. This model is not extendable so the first patch introduces a replacement: notifier to propagate FIB entry additions and removals to whoever is interested.
Although I am disappointed that we need to use notifiers to support fib offloading properly (it seems ad-hoc and hackish), I cannot come up with a better solution to the problem. :-)
So series applied, thanks Jiri!