introduce infrastructure for support of switch chip datapath
Subsystems (10)
v3 cover introduce infrastructure for support of switch chip datapath
The basic idea is to introduce a generic infractructure to support various switch chips in kernel.
The current patchset RFC is a heavy rework of the previous ones. The goal is to be low-intrusive and to use as much as possible from the existing infrastructure.
Also the idea is to benefit from currently existing Open vSwitch userspace infrastructure prividing a HW offload for it. Note that this is just one usecase. Other sw*dev_ndos can be easily added to support many more usecases,
Please see Documentation/networking/switchdev.txt for more details about the model.
Next step would be to introduce a flag via which OVS userspace could tell if the flow should be inserted in HW or just in the SW datapath. That would extend current 2 level cashing (kernel, userspace) to 3 level (hw, kernel, userspace).
Next step would be to improve internal kernel notifiers and introduce a listener which would call sw*dev_ndos to setup the switch according to what the user wants. This would allow a usecase then a user configures bridges, bonds, etc and the switch chip underneath gets configured by that.
Any suggestions, feedbacks welcome.
Jiri Pirko (10):
openvswitch: split flow structures into ovs specific and generic ones
net: rename netdev_phys_port_id to more generic name
net: introduce generic switch devices support
rtnl: expose physical switch id for particular device
switchdev: introduce basic support for flows
net: introduce dummy switch
dsa: implement ndo_swdev_get_id
net: add netdev_for_each_all_lower_dev_rcu helper
openvswitch: introduce vport_op get_netdev
openvswitch: add support for datapath hardware offload
Documentation/networking/switchdev.txt | 53 +++++++ drivers/net/Kconfig | 7 + drivers/net/Makefile | 1 + drivers/net/dummyswitch.c | 126 +++++++++++++++++ drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c | 2 +- drivers/net/ethernet/mellanox/mlx4/en_netdev.c | 2 +- drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c | 2 +- include/linux/netdevice.h | 74 ++++++++-- include/linux/sw_flow.h | 122 ++++++++++++++++ include/linux/switchdev.h | 55 ++++++++ include/uapi/linux/if_link.h | 10 ++ net/Kconfig | 6 + net/core/Makefile | 1 + net/core/dev.c | 28 ++-- net/core/net-sysfs.c | 2 +- net/core/rtnetlink.c | 30 +++- net/core/switchdev.c | 90 ++++++++++++ net/dsa/slave.c | 16 +++ net/openvswitch/Makefile | 3 +- net/openvswitch/datapath.c | 63 +++++---- net/openvswitch/datapath.h | 4 +- net/openvswitch/dp_notify.c | 7 +- net/openvswitch/flow.c | 14 +- net/openvswitch/flow.h | 123 ++++------------ net/openvswitch/flow_netlink.c | 24 ++-- net/openvswitch/flow_netlink.h | 4 +- net/openvswitch/flow_table.c | 100 ++++++------- net/openvswitch/flow_table.h | 18 +-- net/openvswitch/hw_offload.c | 170 +++++++++++++++++++++++ net/openvswitch/hw_offload.h | 31 +++++ net/openvswitch/vport-gre.c | 4 +- net/openvswitch/vport-internal_dev.c | 53 ++++--- net/openvswitch/vport-netdev.c | 16 +++ net/openvswitch/vport-netdev.h | 12 -- net/openvswitch/vport-vxlan.c | 2 +- net/openvswitch/vport.c | 2 +- net/openvswitch/vport.h | 4 +- 37 files changed, 1004 insertions(+), 277 deletions(-) create mode 100644 Documentation/networking/switchdev.txt create mode 100644 drivers/net/dummyswitch.c create mode 100644 include/linux/sw_flow.h create mode 100644 include/linux/switchdev.h create mode 100644 net/core/switchdev.c create mode 100644 net/openvswitch/hw_offload.c create mode 100644 net/openvswitch/hw_offload.h
Signature · 1 line
1.9.0
A message that is not in the archive (sent off-list or not yet received): 1397736876-11771-1-git-send-email-jiri-rHqAuBHg3fBzbRFIqnYvSA@public.gmane.org
RFC PATCH v3 1/10 openvswitch: split flow structures into ovs specific and generic ones
After this, flow related structures can be used in other code.
--- include/linux/sw_flow.h | 108 ++++++++++++++++++++++++++++++++++++ net/openvswitch/datapath.c | 45 +++++++-------- net/openvswitch/datapath.h | 4 +- net/openvswitch/flow.c | 14 ++--- net/openvswitch/flow.h | 123 +++++++++-------------------------------- net/openvswitch/flow_netlink.c | 24 ++++---- net/openvswitch/flow_netlink.h | 4 +- net/openvswitch/flow_table.c | 100 +++++++++++++++++---------------- net/openvswitch/flow_table.h | 18 +++--- net/openvswitch/vport-gre.c | 4 +- net/openvswitch/vport-vxlan.c | 2 +- net/openvswitch/vport.c | 2 +- net/openvswitch/vport.h | 2 +- 13 files changed, 245 insertions(+), 205 deletions(-) create mode 100644 include/linux/sw_flow.h
include/linux/sw_flow.h new file +108 -0
@@ -0,0 +1,108 @@ +/* +* Copyright (c) 2007-2012 Nicira, Inc. +* Copyright (c) 2014 Jiri Pirko <[email protected]> +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of version 2 of the GNU General Public +* License as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, but +* WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +* 02110-1301, USA +*/ + +#ifndef _LINUX_SW_FLOW_H_ +#define _LINUX_SW_FLOW_H_ + +struct sw_flow_key_ipv4_tunnel { +__be64 tun_id; +__be32 ipv4_src; +__be32 ipv4_dst; +__be16 tun_flags; +u8 ipv4_tos; +u8 ipv4_ttl; +}; + +struct sw_flow_key { +struct sw_flow_key_ipv4_tunnel tun_key;/* Encapsulating tunnel key. */ +struct { +u32 priority;/* Packet QoS priority. */ +u32 skb_mark;/* SKB mark. */ +u16 in_port;/* Input switch port (or DP_MAX_PORTS). */ + } phy; +struct { +u8 src[ETH_ALEN ];/* Ethernet source address. */ +u8 dst[ETH_ALEN ];/* Ethernet destination address. */ +__be16 tci;/* 0 if no VLAN, VLAN_TAG_PRESENT set otherwise. */ +__be16 type;/* Ethernet frame type. */ + } eth; +struct { +u8 proto;/* IP protocol or lower 8 bits of ARP opcode. */ +u8 tos;/* IP ToS. */ +u8 ttl;/* IP TTL/hop limit. */ +u8 frag;/* One of OVS_FRAG_TYPE_*. */ + } ip; +union { +struct { +struct { +__be32 src;/* IP source address. */ +__be32 dst;/* IP destination address. */ + } addr; +union { +struct { +__be16 src;/* TCP/UDP/SCTP source port. */ +__be16 dst;/* TCP/UDP/SCTP destination port. */ +__be16 flags;/* TCP flags. */ + } tp; +struct { +u8 sha[ETH_ALEN ];/* ARP source hardware address. */ +u8 tha[ETH_ALEN ];/* ARP target hardware address. */ + } arp; + }; + } ipv4; +struct { +struct { +struct in6_addr src;/* IPv6 source address. */ +struct in6_addr dst;/* IPv6 destination address. */ + } addr; +__be32 label;/* IPv6 flow label. */ +struct { +__be16 src;/* TCP/UDP/SCTP source port. */ +__be16 dst;/* TCP/UDP/SCTP destination port. */ +__be16 flags;/* TCP flags. */ + } tp; +struct { +struct in6_addr target;/* ND target address. */ +u8 sll[ETH_ALEN ];/* ND source link layer address. */ +u8 tll[ETH_ALEN ];/* ND target link layer address. */ + } nd; + } ipv6; + }; +}__aligned(BITS_PER_LONG/8) ;/* Ensure that we can do comparisons as longs. */ + +struct sw_flow_key_range { +unsigned short int start; +unsigned short int end; +}; + +struct sw_flow_mask { +struct sw_flow_key_range range; +struct sw_flow_key key; +}; + +struct sw_flow { +struct sw_flow_key key; +struct sw_flow_key unmasked_key; +struct sw_flow_mask *mask; +}; + +struct sw_flow_action { +} + +#endif /* _LINUX_SW_FLOW_H_ */
net/openvswitch/datapath.c +23 -22
143 lines not on this page · raw message
net/openvswitch/datapath.h +2 -2
@@ -100,9 +100,9 @@ struct datapath {* packet is not being tunneled. */ struct ovs_skb_cb { -struct sw_flow *flow; +struct ovs_flow *flow;struct sw_flow_key *pkt_key; -struct ovs_key_ipv4_tunnel *tun_key; +struct sw_flow_key_ipv4_tunnel *tun_key; };#define OVS_CB (skb) ((struct ovs_skb_cb *)(skb)->cb)
net/openvswitch/flow.c +7 -7
@@ -61,7 +61,7 @@ u64 ovs_flow_used_time(unsigned long flow_jiffies)#define TCP_FLAGS_BE16 (tp) (*(__be16 *)&tcp_flag_word(tp) & htons(0x0FFF)) -void ovs_flow_stats_update (struct sw_flow *flow,struct sk_buff *skb) +void ovs_flow_stats_update (struct ovs_flow *flow,struct sk_buff *skb) {struct flow_stats *stats;__be16 tcp_flags =0 ;
@@ -71,10 +71,10 @@ void ovs_flow_stats_update(struct sw_flow *flow, struct sk_buff *skb)else stats =this_cpu_ptr (flow->stats.cpu_stats); -if ((flow->key.eth.type ==htons (ETH_P_IP ) || - flow->key.eth.type ==htons (ETH_P_IPV6 )) && - flow->key.ip.frag !=OVS_FRAG_TYPE_LATER && - flow->key.ip.proto ==IPPROTO_TCP && +if ((flow->flow.key.eth.type ==htons (ETH_P_IP ) || + flow->flow.key.eth.type ==htons (ETH_P_IPV6 )) && + flow->flow.key.ip.frag !=OVS_FRAG_TYPE_LATER && + flow->flow.key.ip.proto ==IPPROTO_TCP &&likely (skb->len >=skb_transport_offset (skb) +sizeof (struct tcphdr ))) { tcp_flags =TCP_FLAGS_BE16 (tcp_hdr (skb)); }
@@ -100,7 +100,7 @@ static void stats_read(struct flow_stats *stats,spin_unlock (&stats->lock); } -void ovs_flow_stats_get (struct sw_flow *flow,struct ovs_flow_stats *ovs_stats, +void ovs_flow_stats_get (struct ovs_flow *flow,struct ovs_flow_stats *ovs_stats,unsigned long *used,__be16 *tcp_flags) {int cpu;
@@ -133,7 +133,7 @@ static void stats_reset(struct flow_stats *stats)spin_unlock (&stats->lock); } -void ovs_flow_stats_clear (struct sw_flow *flow) +void ovs_flow_stats_clear (struct ovs_flow *flow) {int cpu;
net/openvswitch/flow.h +25 -98
162 lines not on this page · raw message
net/openvswitch/flow_netlink.c +12 -12
@@ -46,7 +46,7 @@#include "flow_netlink.h" -static void update_range__ (struct sw_flow_match *match, +static void update_range__ (struct ovs_flow_match *match,size_t offset,size_t size,bool is_mask) {struct sw_flow_key_range *range =NULL ;
@@ -103,7 +103,7 @@ static u16 range_n_bytes(const struct sw_flow_key_range *range)return range->end - range->start; } -static bool match_validate (const struct sw_flow_match *match, +static bool match_validate (const struct ovs_flow_match *match,u64 key_attrs,u64 mask_attrs) {u64 key_expected =1 <<OVS_KEY_ATTR_ETHERNET ;
@@ -339,7 +339,7 @@ static int parse_flow_nlattrs(const struct nlattr *attr, }static int ipv4_tun_from_nlattr (const struct nlattr *attr, -struct sw_flow_match *match,bool is_mask) +struct ovs_flow_match *match,bool is_mask) {struct nlattr *a;int rem;
@@ -428,8 +428,8 @@ static int ipv4_tun_from_nlattr(const struct nlattr *attr, }static int ipv4_tun_to_nlattr (struct sk_buff *skb, -const struct ovs_key_ipv4_tunnel *tun_key, -const struct ovs_key_ipv4_tunnel *output) +const struct sw_flow_key_ipv4_tunnel *tun_key, +const struct sw_flow_key_ipv4_tunnel *output) {struct nlattr *nla;
@@ -463,7 +463,7 @@ static int ipv4_tun_to_nlattr(struct sk_buff *skb, } -static int metadata_from_nlattrs (struct sw_flow_match *match,u64 *attrs, +static int metadata_from_nlattrs (struct ovs_flow_match *match,u64 *attrs,const struct nlattr **a,bool is_mask) {if (*attrs & (1 <<OVS_KEY_ATTR_PRIORITY )) {
@@ -501,7 +501,7 @@ static int metadata_from_nlattrs(struct sw_flow_match *match, u64 *attrs,return 0 ; } -static int ovs_key_from_nlattrs (struct sw_flow_match *match,bool *exact_5tuple, +static int ovs_key_from_nlattrs (struct ovs_flow_match *match,bool *exact_5tuple,u64 attrs,const struct nlattr **a,bool is_mask) {
@@ -799,7 +799,7 @@ static void sw_flow_mask_set(struct sw_flow_mask *mask,* @mask: Optional. Netlink attribute holding nested %OVS_KEY_ATTR_* Netlink * attribute specifies the mask field of the wildcarded flow. */ -int ovs_nla_get_match (struct sw_flow_match *match, +int ovs_nla_get_match (struct ovs_flow_match *match,bool *exact_5tuple,const struct nlattr *key,const struct nlattr *mask)
@@ -922,11 +922,11 @@ int ovs_nla_get_match(struct sw_flow_match *match,int ovs_nla_get_flow_metadata (struct sw_flow *flow,const struct nlattr *attr) { -struct ovs_key_ipv4_tunnel *tun_key = &flow->key.tun_key; +struct sw_flow_key_ipv4_tunnel *tun_key = &flow->key.tun_key;const struct nlattr *a[OVS_KEY_ATTR_MAX +1 ];u64 attrs =0 ;int err; -struct sw_flow_match match; +struct ovs_flow_match match; flow->key.phy.in_port =DP_MAX_PORTS ; flow->key.phy.priority =0 ;
@@ -1320,7 +1320,7 @@ static int validate_tp_port(const struct sw_flow_key *flow_key)return -EINVAL ; } -void ovs_match_init (struct sw_flow_match *match, +void ovs_match_init (struct ovs_flow_match *match,struct sw_flow_key *key,struct sw_flow_mask *mask) {
@@ -1339,7 +1339,7 @@ void ovs_match_init(struct sw_flow_match *match,static int validate_and_copy_set_tun (const struct nlattr *attr,struct sw_flow_actions **sfa) { -struct sw_flow_match match; +struct ovs_flow_match match;struct sw_flow_key key;int err, start;
net/openvswitch/flow_netlink.h +2 -2
@@ -37,14 +37,14 @@#include "flow.h" -void ovs_match_init (struct sw_flow_match *match, +void ovs_match_init (struct ovs_flow_match *match,struct sw_flow_key *key,struct sw_flow_mask *mask);int ovs_nla_put_flow (const struct sw_flow_key *,const struct sw_flow_key *,struct sk_buff *);int ovs_nla_get_flow_metadata (struct sw_flow *flow,const struct nlattr *attr); -int ovs_nla_get_match (struct sw_flow_match *match, +int ovs_nla_get_match (struct ovs_flow_match *match,bool *exact_5tuple,const struct nlattr *,const struct nlattr *);
net/openvswitch/flow_table.c +52 -48
261 lines not on this page · raw message
net/openvswitch/flow_table.h +9 -9
@@ -55,28 +55,28 @@ struct flow_table {int ovs_flow_init (void );void ovs_flow_exit (void ); -struct sw_flow *ovs_flow_alloc (bool percpu_stats); -void ovs_flow_free (struct sw_flow *,bool deferred); +struct ovs_flow *ovs_flow_alloc (bool percpu_stats); +void ovs_flow_free (struct ovs_flow *,bool deferred);int ovs_flow_tbl_init (struct flow_table *);int ovs_flow_tbl_count (struct flow_table *table);void ovs_flow_tbl_destroy (struct flow_table *table,bool deferred);int ovs_flow_tbl_flush (struct flow_table *flow_table); -int ovs_flow_tbl_insert (struct flow_table *table,struct sw_flow *flow, +int ovs_flow_tbl_insert (struct flow_table *table,struct ovs_flow *flow,struct sw_flow_mask *mask); -void ovs_flow_tbl_remove (struct flow_table *table,struct sw_flow *flow); +void ovs_flow_tbl_remove (struct flow_table *table,struct ovs_flow *flow);int ovs_flow_tbl_num_masks (const struct flow_table *table); -struct sw_flow *ovs_flow_tbl_dump_next (struct table_instance *table, +struct ovs_flow *ovs_flow_tbl_dump_next (struct table_instance *table,u32 *bucket,u32 *idx); -struct sw_flow *ovs_flow_tbl_lookup_stats (struct flow_table *, +struct ovs_flow *ovs_flow_tbl_lookup_stats (struct flow_table *,const struct sw_flow_key *,u32 *n_mask_hit); -struct sw_flow *ovs_flow_tbl_lookup (struct flow_table *, +struct ovs_flow *ovs_flow_tbl_lookup (struct flow_table *,const struct sw_flow_key *); -bool ovs_flow_cmp_unmasked_key (const struct sw_flow *flow, -struct sw_flow_match *match); +bool ovs_flow_cmp_unmasked_key (const struct ovs_flow *flow, +struct ovs_flow_match *match);void ovs_flow_mask_key (struct sw_flow_key *dst,const struct sw_flow_key *src,const struct sw_flow_mask *mask);
net/openvswitch/vport-gre.c +2 -2
@@ -63,7 +63,7 @@ static __be16 filter_tnl_flags(__be16 flags)static struct sk_buff *__build_header (struct sk_buff *skb,int tunnel_hlen) { -const struct ovs_key_ipv4_tunnel *tun_key =OVS_CB (skb)->tun_key; +const struct sw_flow_key_ipv4_tunnel *tun_key =OVS_CB (skb)->tun_key;struct tnl_ptk_info tpi; skb =gre_handle_offloads (skb, !!(tun_key->tun_flags &TUNNEL_CSUM ));
@@ -92,7 +92,7 @@ static __be64 key_to_tunnel_id(__be32 key, __be32 seq)static int gre_rcv (struct sk_buff *skb,const struct tnl_ptk_info *tpi) { -struct ovs_key_ipv4_tunnel tun_key; +struct sw_flow_key_ipv4_tunnel tun_key;struct ovs_net *ovs_net;struct vport *vport;__be64 key;
net/openvswitch/vport-vxlan.c +1 -1
@@ -58,7 +58,7 @@ static inline struct vxlan_port *vxlan_vport(const struct vport *vport)/* Called with rcu_read_lock and BH disabled. */ static void vxlan_rcv (struct vxlan_sock *vs,struct sk_buff *skb,__be32 vx_vni) { -struct ovs_key_ipv4_tunnel tun_key; +struct sw_flow_key_ipv4_tunnel tun_key;struct vport *vport = vs->data;struct iphdr *iph;__be64 key;
net/openvswitch/vport.c +1 -1
@@ -337,7 +337,7 @@ int ovs_vport_get_options(const struct vport *vport, struct sk_buff *skb)* skb->data should point to the Ethernet header. */ void ovs_vport_receive (struct vport *vport,struct sk_buff *skb, -struct ovs_key_ipv4_tunnel *tun_key) +struct sw_flow_key_ipv4_tunnel *tun_key) {struct pcpu_sw_netstats *stats;
net/openvswitch/vport.h +1 -1
@@ -191,7 +191,7 @@ static inline struct vport *vport_from_priv(const void *priv) }void ovs_vport_receive (struct vport *,struct sk_buff *, -struct ovs_key_ipv4_tunnel *); +struct sw_flow_key_ipv4_tunnel *);/* List of statically compiled vport implementations. Don't forget to also * add yours to the list at the top of vport.c. */
Signature · 1 line
1.9.0
RFC PATCH v3 6/10 net: introduce dummy switch
In reply to a message not in the archiveDummy switch implementation using switchdev interface
--- drivers/net/Kconfig | 7 +++ drivers/net/Makefile | 1 + drivers/net/dummyswitch.c | 126 +++++++++++++++++++++++++++++++++++++++++++ include/uapi/linux/if_link.h | 9 ++++ 4 files changed, 143 insertions(+) create mode 100644 drivers/net/dummyswitch.c
drivers/net/Kconfig +7 -0
@@ -71,6 +71,13 @@ config DUMMY To compile this driver as a module, choose M here: the module will be called dummy. +config NET_DUMMY_SWITCH + tristate "Dummy switch net driver support" + depends on NET_SWITCHDEV + ---help--- + To compile this driver as a module, choose M here: the module + will be called dummyswitch. + config EQUALIZER tristate "EQL (serial line load balancing) support" ---help---
drivers/net/Makefile +1 -0
@@ -7,6 +7,7 @@ # obj-$(CONFIG_BONDING) += bonding/ obj-$(CONFIG_DUMMY) += dummy.o +obj-$(CONFIG_NET_DUMMY_SWITCH) += dummyswitch.o obj-$(CONFIG_EQUALIZER) += eql.o obj-$(CONFIG_IFB) += ifb.o obj-$(CONFIG_MACVLAN) += macvlan.o
drivers/net/dummyswitch.c new file +126 -0
126 lines not on this page · raw message
include/uapi/linux/if_link.h +9 -0
@@ -546,4 +546,13 @@ enum {#define IFLA_HSR_MAX (__IFLA_HSR_MAX - 1) +/* DUMMYSWPORT section */ +enum { +IFLA_DUMMYSWPORT_UNSPEC , +IFLA_DYMMYSWPORT_PHYS_SWITCH_ID , + __IFLA_DUMMYSWPORT_MAX, +}; + +#define IFLA_DUMMYSWPORT_MAX (__IFLA_DUMMYSWPORT_MAX - 1) +#endif /* _UAPI_LINUX_IF_LINK_H */
Signature · 1 line
1.9.0
RFC PATCH v3 8/10 net: add netdev_for_each_all_lower_dev_rcu helper
In reply to a message not in the archive--- include/linux/netdevice.h | 18 +++++++++++++----- net/core/dev.c | 26 ++++++++++++++------------ 2 files changed, 27 insertions(+), 17 deletions(-)
include/linux/netdevice.h +13 -5
@@ -3076,15 +3076,23 @@ extern int weight_p;extern int bpf_jit_enable;bool netdev_has_upper_dev (struct net_device *dev,struct net_device *upper_dev); -struct net_device *netdev_all_upper_get_next_dev_rcu (struct net_device *dev, -struct list_head **iter); +struct net_device *netdev_all_adj_get_next_dev_rcu (struct net_device *dev, +struct list_head **iter, +struct list_head *adj_list);/* iterate through upper list, must be called under RCU read lock */ #define netdev_for_each_all_upper_dev_rcu (dev, updev, iter) \ - for (iter = &(dev)->all_adj_list.upper, \ - updev = netdev_all_upper_get_next_dev_rcu(dev, &(iter)); \ + for (iter = NULL, \ + updev = netdev_all_adj_get_next_dev_rcu(dev, &(iter), &(dev)->all_adj_list.upper); \ updev; \ - updev = netdev_all_upper_get_next_dev_rcu(dev, &(iter))) + updev = netdev_all_adj_get_next_dev_rcu(dev, &(iter), &(dev)->all_adj_list.upper)) + +/* iterate through lower list, must be called under RCU read lock */ +#define netdev_for_each_all_lower_dev_rcu (dev, lodev, iter) \ + for (iter = NULL, \ + lodev = netdev_all_adj_get_next_dev_rcu(dev, &(iter), &(dev)->all_adj_list.lower); \ + lodev; \ + lodev = netdev_all_adj_get_next_dev_rcu(dev, &(iter), &(dev)->all_adj_list.lower))void *netdev_lower_get_next_private (struct net_device *dev,struct list_head **iter);
net/core/dev.c +14 -12
@@ -4542,30 +4542,32 @@ void *netdev_adjacent_get_private(struct list_head *adj_list)EXPORT_SYMBOL (netdev_adjacent_get_private);/** -* netdev_all_upper_get_next_dev_rcu - Get the next dev from upper list +* netdev_all_adj_get_next_dev_rcu - Get the next dev from adjacent list * @dev: device * @iter: list_head ** of the current position +* @adj_list: adjacent list to go through * -* Gets the next device from the dev's upper list, starting from iter +* Gets the next device from the dev's adjacent list, starting from iter * position. The caller must hold RCU read lock. */ -struct net_device *netdev_all_upper_get_next_dev_rcu (struct net_device *dev, -struct list_head **iter) +struct net_device *netdev_all_adj_get_next_dev_rcu (struct net_device *dev, +struct list_head **iter, +struct list_head *adj_list) { -struct netdev_adjacent *upper; +struct netdev_adjacent *adj;WARN_ON_ONCE (!rcu_read_lock_held () && !lockdep_rtnl_is_held ()); - upper = list_entry_rcu((*iter)->next, struct netdev_adjacent, list); - -if (&upper->list == &dev->all_adj_list.upper) +if (!*iter) + *iter = adj_list; +if ((*iter)->next == adj_list)return NULL ; - *iter = &upper->list; - -return upper->dev; + adj = list_entry_rcu((*iter)->next, struct netdev_adjacent, list); + *iter = &adj->list; +return adj->dev; } -EXPORT_SYMBOL (netdev_all_upper_get_next_dev_rcu); +EXPORT_SYMBOL (netdev_all_adj_get_next_dev_rcu);/** * netdev_lower_get_next_private - Get the next ->private from the
Signature · 1 line
1.9.0
RFC PATCH v3 10/10 openvswitch: add support for datapath hardware offload
In reply to a message not in the archiveBenefit from the possibility to work with flows in switch devices and use the swdev api to offload flow datapath.
--- include/linux/sw_flow.h | 16 +++- net/openvswitch/Makefile | 3 +- net/openvswitch/datapath.c | 16 +++- net/openvswitch/hw_offload.c | 170 +++++++++++++++++++++++++++++++++++++++++++ net/openvswitch/hw_offload.h | 31 ++++++++ 5 files changed, 231 insertions(+), 5 deletions(-) create mode 100644 net/openvswitch/hw_offload.c create mode 100644 net/openvswitch/hw_offload.h
include/linux/sw_flow.h +15 -1
@@ -102,7 +102,21 @@ struct sw_flow { struct sw_flow_mask *mask; }; +enum sw_flow_action_type { +SW_FLOW_ACTION_TYPE_OUTPUT , +SW_FLOW_ACTION_TYPE_VLAN_PUSH , +SW_FLOW_ACTION_TYPE_VLAN_POP , +}; +struct sw_flow_action { -} +enum sw_flow_action_type type; +union { +struct net_device *output_dev; +struct { +__be16 vlan_proto; +u16 vlan_tci; + } vlan; + }; +};#endif /* _LINUX_SW_FLOW_H_ */
net/openvswitch/Makefile +2 -1
@@ -13,7 +13,8 @@ openvswitch-y := \ flow_table.o \ vport.o \ vport-internal_dev.o \ - vport-netdev.o + vport-netdev.o \ + hw_offload.o ifneq ($(CONFIG_OPENVSWITCH_VXLAN),) openvswitch-y += vport-vxlan.o
net/openvswitch/datapath.c +13 -3
@@ -59,6 +59,7 @@#include "flow_netlink.h" #include "vport-internal_dev.h" #include "vport-netdev.h" +#include "hw_offload.h" int ovs_net_id__read_mostly ;
@@ -840,13 +841,15 @@ static int ovs_flow_cmd_new_or_set(struct sk_buff *skb, struct genl_info *info) flow->flow.key = masked_key; flow->flow.unmasked_key = key;rcu_assign_pointer (flow->sf_acts, acts); + acts =NULL ;/* Put flow in bucket. */ error =ovs_flow_tbl_insert (&dp->table, flow, &mask); -if (error) { - acts =NULL ; +if (error) goto err_flow_free; - } + error =ovs_hw_flow_insert (dp, flow, flow->sf_acts); +if (error) + goto err_flow_tbl_remove; reply =ovs_flow_cmd_build_info (flow, dp, info,OVS_FLOW_CMD_NEW ); }else {
@@ -868,6 +871,10 @@ static int ovs_flow_cmd_new_or_set(struct sk_buff *skb, struct genl_info *info)if (!ovs_flow_cmp_unmasked_key (flow, &match)) goto err_unlock_ovs; + error =ovs_hw_flow_actions_update (dp, flow, acts); +if (error) + goto err_unlock_ovs; +/* Update actions. */ old_acts =ovsl_dereference (flow->sf_acts);rcu_assign_pointer (flow->sf_acts, acts);
@@ -888,6 +895,8 @@ static int ovs_flow_cmd_new_or_set(struct sk_buff *skb, struct genl_info *info) 0, PTR_ERR(reply));return 0 ; +err_flow_tbl_remove: +ovs_flow_tbl_remove (&dp->table, flow); err_flow_free:ovs_flow_free (flow, false); err_unlock_ovs:
@@ -985,6 +994,7 @@ static int ovs_flow_cmd_del(struct sk_buff *skb, struct genl_info *info) goto unlock; } +ovs_hw_flow_remove (dp, flow);ovs_flow_tbl_remove (&dp->table, flow); err = ovs_flow_cmd_fill_info(flow, dp, reply, info->snd_portid,
net/openvswitch/hw_offload.c new file +170 -0
170 lines not on this page · raw message
net/openvswitch/hw_offload.h new file +31 -0
@@ -0,0 +1,31 @@ +/* +* Copyright (c) 2014 Jiri Pirko <[email protected]> +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of version 2 of the GNU General Public +* License as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, but +* WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +* 02110-1301, USA +*/ + +#ifndef HW_OFFLOAD_H +#define HW_OFFLOAD_H 1 + +#include "datapath.h" +#include "flow.h" + +int ovs_hw_flow_insert (struct datapath *dp,struct ovs_flow *flow, +struct sw_flow_actions *acts); +void ovs_hw_flow_remove (struct datapath *dp,struct ovs_flow *flow); +int ovs_hw_flow_actions_update (struct datapath *dp,struct ovs_flow *flow, +struct sw_flow_actions *acts); + +#endif
Signature · 1 line
1.9.0
A message that is not in the archive (sent off-list or not yet received): 1397736938-11838-1-git-send-email-jiri-rHqAuBHg3fBzbRFIqnYvSA@public.gmane.org
Re: [patch net-next RFC v3 10/10] openvswitch: add support for datapath hardware offload
Quoted 5 lines · Jiri Pirko
Benefit from the possibility to work with flows in switch devices and use the swdev api to offload flow datapath.
Signed-off-by Jiri Pirko <[email protected]>---
[...]
Quoted 10 lines
net/openvswitch/datapath.c +1
-1@@ -840,13 +841,15 @@ static int ovs_flow_cmd_new_or_set(struct sk_buff *skb, struct genl_info *info) flow->flow.key = masked_key; flow->flow.unmasked_key = key;rcu_assign_pointer (flow->sf_acts, acts); + acts =NULL ;/* Put flow in bucket. */ error =ovs_flow_tbl_insert (&dp->table, flow, &mask); -if (error) {
net/openvswitch/datapath.c static int ovs_flow_cmd_new_or_set(struct sk_buff *skb, struct genl_info *info) · line 855
Quoted 10 lines
net/openvswitch/datapath.c +4
-2- acts =NULL ; +if (error) goto err_flow_free; - } + error =ovs_hw_flow_insert (dp, flow, flow->sf_acts); +if (error) + goto err_flow_tbl_remove; reply =ovs_flow_cmd_build_info (flow, dp, info,OVS_FLOW_CMD_NEW ); }else {
Hi Jiri,
If I read this correctly it looks like you do a insert into software flow tables and then an insert into the hardware flow tables. Into all lowerdevs. Let me know if I got this wrong.
This might break on some rules (an insert tag for example) and also underutilize the switch resources by pushing rules into the switch that we really only need in software tables or maybe only on some set of ports.
I think we need to allow applications direct access to the flow table via netlink so I can write my policy in user space and not require OVS. If OVS wants to support a mode where it does this automagically it can support it in userspace and the kernel side does not need to change.
Thanks,
John
Signature · 1 line
John Fastabend Intel Corporation
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [patch net-next RFC v3 10/10] openvswitch: add support for datapath hardware offload
Quoted 28 lines · Thu, Apr 24, 2014 at 04:54:19PM CEST, john.fastabend-Re5JQEeQqe8AvxtiuMwx3w@pub…
Quoted 5 lines · Jiri Pirko
Benefit from the possibility to work with flows in switch devices and use the swdev api to offload flow datapath.
Signed-off-by Jiri Pirko <[email protected]>---
[...]
Quoted 18 lines
net/openvswitch/datapath.c +5
-3@@ -840,13 +841,15 @@ static int ovs_flow_cmd_new_or_set(struct sk_buff *skb, struct genl_info *info) flow->flow.key = masked_key; flow->flow.unmasked_key = key;rcu_assign_pointer (flow->sf_acts, acts); + acts =NULL ;/* Put flow in bucket. */ error =ovs_flow_tbl_insert (&dp->table, flow, &mask); -if (error) { - acts =NULL ; +if (error) goto err_flow_free; - } + error =ovs_hw_flow_insert (dp, flow, flow->sf_acts); +if (error) + goto err_flow_tbl_remove;
Quoted 8 lines
net/openvswitch/datapath.c static int ovs_flow_cmd_new_or_set(struct sk_buff *skb, struct genl_info *info) · line 855
Quoted 2 lines
net/openvswitch/datapath.c +0
-0reply =ovs_flow_cmd_build_info (flow, dp, info,OVS_FLOW_CMD_NEW ); }else {Hi Jiri,
If I read this correctly it looks like you do a insert into software flow tables and then an insert into the hardware flow tables. Into all lowerdevs. Let me know if I got this wrong.
It should be sufficient to use one-port-per-switch to insert this. I just insert it to all and if 2 ports of the same switch are used the switch should see that the flow is already there and bail out. This is rough so far. Needs some polishing.
Quoted 5 lines
This might break on some rules (an insert tag for example) and also underutilize the switch resources by pushing rules into the switch that we really only need in software tables or maybe only on some set of ports.
I thought that I would introduce a flag that would say "push this flow to hw".
Quoted 6 lines
I think we need to allow applications direct access to the flow table via netlink so I can write my policy in user space and not require OVS. If OVS wants to support a mode where it does this automagically it can support it in userspace and the kernel side does not need to change.
The idea was to use the existing ovs api for this so it would be smooth to userspace. For non-ovs usage there is certainly possible to introduce new iface which would just call same ndos.
Quoted 7 lines
Thanks,
JohnSignature · 1 line
John Fastabend Intel Corporation
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [patch net-next RFC v3 10/10] openvswitch: add support for datapath hardware offload
Quoted 34 lines · Jiri Pirko
Quoted 33 lines · Thu, Apr 24, 2014 at 04:54:19PM CEST, john.fastabend-Re5JQEeQqe8AvxtiuMwx3w@pub…
Quoted 5 lines · Jiri Pirko
Benefit from the possibility to work with flows in switch devices and use the swdev api to offload flow datapath.
Signed-off-by Jiri Pirko <[email protected]>---
[...]
Quoted 10 lines
net/openvswitch/datapath.c +1
-1@@ -840,13 +841,15 @@ static int ovs_flow_cmd_new_or_set(struct sk_buff *skb, struct genl_info *info) flow->flow.key = masked_key; flow->flow.unmasked_key = key;rcu_assign_pointer (flow->sf_acts, acts); + acts =NULL ;/* Put flow in bucket. */ error =ovs_flow_tbl_insert (&dp->table, flow, &mask); -if (error) {net/openvswitch/datapath.c static int ovs_flow_cmd_new_or_set(struct sk_buff *skb, struct genl_info *info) · line 855
Quoted 10 lines
net/openvswitch/datapath.c +4
-2- acts =NULL ; +if (error) goto err_flow_free; - } + error =ovs_hw_flow_insert (dp, flow, flow->sf_acts); +if (error) + goto err_flow_tbl_remove; reply =ovs_flow_cmd_build_info (flow, dp, info,OVS_FLOW_CMD_NEW ); }else {Hi Jiri,
Quoted 10 lines
Quoted 3 lines
If I read this correctly it looks like you do a insert into software flow tables and then an insert into the hardware flow tables. Into all lowerdevs. Let me know if I got this wrong.
It should be sufficient to use one-port-per-switch to insert this. I just insert it to all and if 2 ports of the same switch are used the switch should see that the flow is already there and bail out. This is rough so far. Needs some polishing.
OK that seems fine.
Quoted 9 lines
Quoted 5 lines
This might break on some rules (an insert tag for example) and also underutilize the switch resources by pushing rules into the switch that we really only need in software tables or maybe only on some set of ports.
I thought that I would introduce a flag that would say "push this flow to hw".
Great this would align with how the FDB interface works. I think this is a good model although I would prefer a bitfield so I can push it to hardware, or sw, or both.
Quoted 11 lines
Quoted 6 lines
I think we need to allow applications direct access to the flow table via netlink so I can write my policy in user space and not require OVS. If OVS wants to support a mode where it does this automagically it can support it in userspace and the kernel side does not need to change.
The idea was to use the existing ovs api for this so it would be smooth to userspace. For non-ovs usage there is certainly possible to introduce new iface which would just call same ndos.
If we get a bitfield to push to just hardware and just software then using the OVS interface is probably ok. We also need someway to expose capabilities.
Anyways not a bad start. We can clean it up when the hardware support is ready.
.John
v3 cover iproute2: support switch chip infrastructure
In reply to a message not in the archiveJiri Pirko (5):
iproute2: arpd: use ll_addr_a2n and ll_addr_n2a
iproute2: utils: change hexstring_n2a and hexstring_a2n to do not work
with ":"
iproute2: ipa: show switch id
iproute2: add support for dummyswport
iproute2: ipa: show port id
include/linux/if_link.h | 11 ++++++++++ ip/Makefile | 3 ++- ip/ipaddress.c | 16 ++++++++++++++ ip/iplink_dummyswport.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++++ lib/utils.c | 46 ++++++++++++---------------------------- misc/arpd.c | 6 +++--- 6 files changed, 101 insertions(+), 37 deletions(-) create mode 100644 ip/iplink_dummyswport.c
Signature · 1 line
1.9.0
A message that is not in the archive (sent off-list or not yet received): 1397737053-11892-1-git-send-email-jiri-rHqAuBHg3fBzbRFIqnYvSA@public.gmane.org
RFC PATCH v3 1/5 iproute2: arpd: use ll_addr_a2n and ll_addr_n2a
--- misc/arpd.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
misc/arpd.c +3 -3
@@ -36,6 +36,7 @@#include "libnetlink.h" #include "utils.h" +#include "rt_names.h" int resolve_hosts;
@@ -721,8 +722,7 @@ int main(int argc, char **argv) goto do_abort; } - dbdat.data =hexstring_a2n (macbuf, b1,6 ); -if (dbdat.data ==NULL ) +if (ll_addr_a2n ((char *) b1,6 , macbuf) !=6 ) goto do_abort; dbdat.size =6 ;
@@ -747,7 +747,7 @@ int main(int argc, char **argv)printf ("%-8d %-15s %s\n" , key->iface,inet_ntoa (*(struct in_addr *)&key->addr), -hexstring_n2a (dbdat.data,6 , b1,18 )); +ll_addr_n2a (dbdat.data,6 ,ARPHRD_ETHER , b1,18 )); }else { printf("%-8d %-15s FAILED: %dsec ago\n", key->iface,
Signature · 1 line
1.9.0
RFC PATCH v3 2/5 iproute2: utils: change hexstring_n2a and hexstring_a2n to do not work with ":"
In reply to a message not in the archive--- lib/utils.c | 46 +++++++++++++--------------------------------- 1 file changed, 13 insertions(+), 33 deletions(-)
lib/utils.c +13 -33
@@ -743,10 +743,6 @@ char *hexstring_n2a(const __u8 *str, int len, char *buf, int blen)sprintf (ptr,"%02x" , str[i]); ptr +=2 ; blen -=2 ; -if (i != len-1 && blen >1 ) { - *ptr++ =':' ; - blen--; - } }return buf; }
@@ -754,38 +750,22 @@ char *hexstring_n2a(const __u8 *str, int len, char *buf, int blen)__u8 *hexstring_a2n (const char *str,__u8 *buf,int blen) {int cnt =0 ; +char *endptr; -for (;;) { -unsigned acc; -char ch; - - acc =0 ; - -while ((ch = *str) !=':' && ch !=0 ) { -if (ch >='0' && ch <='9' ) - ch -='0' ; -else if (ch >='a' && ch <='f' ) - ch -='a' -10 ; -else if (ch >='A' && ch <='F' ) - ch -='A' -10 ; -else -return NULL ; - acc = (acc<<4 ) + ch; - str++; - } - -if (acc >255 ) +if (strlen (str) %2 ) +return NULL ; +while (cnt < blen &&strlen (str) >1 ) { +unsigned int tmp; +char tmpstr[3 ]; + +strncpy (tmpstr, str,2 ); + tmpstr[2 ] ='\0' ; + tmp =strtoul (tmpstr, &endptr,16 ); +if (errno !=0 || tmp >0xFF || *endptr !='\0' )return NULL ; -if (cnt < blen) { - buf[cnt] = acc; - cnt++; - } -if (ch ==0 ) -break ; - ++str; + buf[cnt++] = tmp; + str +=2 ; } -if (cnt < blen) -memset (buf+cnt,0 , blen-cnt);return buf; }
Signature · 1 line
1.9.0
RFC PATCH v3 3/5 iproute2: ipa: show switch id
In reply to a message not in the archive--- include/linux/if_link.h | 2 ++ ip/ipaddress.c | 8 ++++++++ 2 files changed, 10 insertions(+)
include/linux/if_link.h +2 -0
@@ -144,6 +144,8 @@ enum {IFLA_NUM_RX_QUEUES ,IFLA_CARRIER ,IFLA_PHYS_PORT_ID , +IFLA_CARRIER_CHANGES , +IFLA_PHYS_SWITCH_ID , __IFLA_MAX };
ip/ipaddress.c +8 -0
@@ -470,6 +470,14 @@ int print_linkinfo(const struct sockaddr_nl *who,fprintf (fp,"master %s " ,ll_idx_n2a (*(int *)RTA_DATA (tb[IFLA_MASTER ]), b1)); } +if (tb[IFLA_PHYS_SWITCH_ID ]) { +SPRINT_BUF (b1); +fprintf (fp,"swid %s " , +hexstring_n2a (RTA_DATA (tb[IFLA_PHYS_SWITCH_ID ]), +RTA_PAYLOAD (tb[IFLA_PHYS_SWITCH_ID ]), + b1,sizeof (b1))); + } +if (tb[IFLA_OPERSTATE ])print_operstate (fp,rta_getattr_u8 (tb[IFLA_OPERSTATE ]));
Signature · 1 line
1.9.0
RFC PATCH v3 4/5 iproute2: add support for dummyswport
In reply to a message not in the archive--- include/linux/if_link.h | 9 ++++++++ ip/Makefile | 3 ++- ip/iplink_dummyswport.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 ip/iplink_dummyswport.c
include/linux/if_link.h +9 -0
@@ -544,4 +544,13 @@ enum {#define IFLA_HSR_MAX (__IFLA_HSR_MAX - 1) +/* DUMMYSWPORT section */ +enum { +IFLA_DUMMYSWPORT_UNSPEC , +IFLA_DYMMYSWPORT_PHYS_SWITCH_ID , + __IFLA_DUMMYSWPORT_MAX, +}; + +#define IFLA_DUMMYSWPORT_MAX (__IFLA_DUMMYSWPORT_MAX - 1) +#endif /* _LINUX_IF_LINK_H */
ip/Makefile +2 -1
@@ -5,7 +5,8 @@ IPOBJ=ip.o ipaddress.o ipaddrlabel.o iproute.o iprule.o ipnetns.o \ iplink_vlan.o link_veth.o link_gre.o iplink_can.o \ iplink_macvlan.o iplink_macvtap.o ipl2tp.o link_vti.o \ iplink_vxlan.o tcp_metrics.o iplink_ipoib.o ipnetconf.o link_ip6tnl.o \ - link_iptnl.o link_gre6.o iplink_bond.o iplink_bond_slave.o iplink_hsr.o + link_iptnl.o link_gre6.o iplink_bond.o iplink_bond_slave.o iplink_hsr.o \ + iplink_dummyswport.o \ RTMONOBJ=rtmon.o
ip/iplink_dummyswport.c new file +56 -0
56 lines not on this page · raw message
Signature · 1 line
1.9.0
Re: [patch iproute2 RFC v3 4/5] iproute2: add support for dummyswport
Quoted 7 lines · Jiri Pirko
Signed-off-by Jiri Pirko <[email protected]>--- include/linux/if_link.h | 9 ++++++++ ip/Makefile | 3 ++- ip/iplink_dummyswport.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 67 insertions(+), 1 deletion(-)create mode 100644
ip/iplink_dummyswport.c
Don't forget to update iplink_usage() in ip/iplink.c, with the new type.
RFC PATCH v3 5/5 iproute2: ipa: show port id
In reply to a message not in the archive--- ip/ipaddress.c | 8 ++++++++ 1 file changed, 8 insertions(+)
ip/ipaddress.c +8 -0
@@ -470,6 +470,14 @@ int print_linkinfo(const struct sockaddr_nl *who,fprintf (fp,"master %s " ,ll_idx_n2a (*(int *)RTA_DATA (tb[IFLA_MASTER ]), b1)); } +if (tb[IFLA_PHYS_PORT_ID ]) { +SPRINT_BUF (b1); +fprintf (fp,"portid %s " , +hexstring_n2a (RTA_DATA (tb[IFLA_PHYS_PORT_ID ]), +RTA_PAYLOAD (tb[IFLA_PHYS_PORT_ID ]), + b1,sizeof (b1))); + } +if (tb[IFLA_PHYS_SWITCH_ID ]) {SPRINT_BUF (b1); fprintf(fp, "swid %s ",
Signature · 1 line
1.9.0
RFC PATCH v3 2/10 net: rename netdev_phys_port_id to more generic name
In reply to Jiri PirkoSo this can be reused for identification of other "items" as well.
--- drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c | 2 +- drivers/net/ethernet/mellanox/mlx4/en_netdev.c | 2 +- drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c | 2 +- include/linux/netdevice.h | 16 ++++++++-------- net/core/dev.c | 2 +- net/core/net-sysfs.c | 2 +- net/core/rtnetlink.c | 6 +++--- 7 files changed, 16 insertions(+), 16 deletions(-)
drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c +1 -1
@@ -12360,7 +12360,7 @@ static int bnx2x_validate_addr(struct net_device *dev) }static int bnx2x_get_phys_port_id (struct net_device *netdev, -struct netdev_phys_port_id *ppid) +struct netdev_phys_item_id *ppid) {struct bnx2x *bp =netdev_priv (netdev);
drivers/net/ethernet/mellanox/mlx4/en_netdev.c +1 -1
@@ -2251,7 +2251,7 @@ static int mlx4_en_set_vf_link_state(struct net_device *dev, int vf, int link_st#define PORT_ID_BYTE_LEN 8static int mlx4_en_get_phys_port_id (struct net_device *dev, -struct netdev_phys_port_id *ppid) +struct netdev_phys_item_id *ppid) {struct mlx4_en_priv *priv =netdev_priv (dev);struct mlx4_dev *mdev = priv->mdev->dev;
drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c +1 -1
@@ -450,7 +450,7 @@ static void qlcnic_82xx_cancel_idc_work(struct qlcnic_adapter *adapter) }static int qlcnic_get_phys_port_id (struct net_device *netdev, -struct netdev_phys_port_id *ppid) +struct netdev_phys_item_id *ppid) {struct qlcnic_adapter *adapter =netdev_priv (netdev);struct qlcnic_hardware_context *ahw = adapter->ahw;
include/linux/netdevice.h +8 -8
@@ -735,13 +735,13 @@ struct netdev_fcoe_hbainfo { };#endif -#define MAX_PHYS_PORT_ID_LEN 32 +#define MAX_PHYS_ITEM_ID_LEN 32 -/* This structure holds a unique identifier to identify the -* physical port used by a netdevice. +/* This structure holds a unique identifier to identify some +* physical item (port for example) used by a netdevice. */ -struct netdev_phys_port_id { -unsigned char id[MAX_PHYS_PORT_ID_LEN ]; +struct netdev_phys_item_id { +unsigned char id[MAX_PHYS_ITEM_ID_LEN ];unsigned char id_len; };
@@ -955,7 +955,7 @@ typedef u16 (*select_queue_fallback_t)(struct net_device *dev,* USB_CDC_NOTIFY_NETWORK_CONNECTION) should NOT implement this function. * * int (*ndo_get_phys_port_id)(struct net_device *dev, -* struct netdev_phys_port_id *ppid); +* struct netdev_phys_item_id *ppid); * Called to get ID of physical port of this device. If driver does * not implement this, it is assumed that the hw is not able to have * multiple net devices on single physical port.
@@ -1121,7 +1121,7 @@ struct net_device_ops {int (*ndo_change_carrier)(struct net_device *dev,bool new_carrier);int (*ndo_get_phys_port_id)(struct net_device *dev, -struct netdev_phys_port_id *ppid); +struct netdev_phys_item_id *ppid);void (*ndo_add_vxlan_port)(struct net_device *dev,sa_family_t sa_family,__be16 port);
@@ -2616,7 +2616,7 @@ void dev_set_group(struct net_device *, int);int dev_set_mac_address (struct net_device *,struct sockaddr *);int dev_change_carrier (struct net_device *,bool new_carrier);int dev_get_phys_port_id (struct net_device *dev, -struct netdev_phys_port_id *ppid); +struct netdev_phys_item_id *ppid);int dev_hard_start_xmit (struct sk_buff *skb,struct net_device *dev,struct netdev_queue *txq);int dev_forward_skb (struct net_device *dev,struct sk_buff *skb);
net/core/dev.c +1 -1
@@ -5512,7 +5512,7 @@ EXPORT_SYMBOL(dev_change_carrier);* Get device physical port ID */ int dev_get_phys_port_id (struct net_device *dev, -struct netdev_phys_port_id *ppid) +struct netdev_phys_item_id *ppid) {const struct net_device_ops *ops = dev->netdev_ops;
net/core/net-sysfs.c +1 -1
@@ -368,7 +368,7 @@ static ssize_t phys_port_id_show(struct device *dev,return restart_syscall ();if (dev_isalive (netdev)) { -struct netdev_phys_port_id ppid; +struct netdev_phys_item_id ppid; ret =dev_get_phys_port_id (netdev, &ppid);if (!ret)
net/core/rtnetlink.c +3 -3
@@ -829,7 +829,7 @@ static noinline size_t if_nlmsg_size(const struct net_device *dev, +rtnl_port_size (dev)/* IFLA_VF_PORTS + IFLA_PORT_SELF */ +rtnl_link_get_size (dev)/* IFLA_LINKINFO */ +rtnl_link_get_af_size (dev)/* IFLA_AF_SPEC */ - +nla_total_size (MAX_PHYS_PORT_ID_LEN );/* IFLA_PHYS_PORT_ID */ + +nla_total_size (MAX_PHYS_ITEM_ID_LEN );/* IFLA_PHYS_PORT_ID */ }static int rtnl_vf_ports_fill (struct sk_buff *skb,struct net_device *dev)
@@ -911,7 +911,7 @@ static int rtnl_port_fill(struct sk_buff *skb, struct net_device *dev)static int rtnl_phys_port_id_fill (struct sk_buff *skb,struct net_device *dev) {int err; -struct netdev_phys_port_id ppid; +struct netdev_phys_item_id ppid; err =dev_get_phys_port_id (dev, &ppid);if (err) {
@@ -1149,7 +1149,7 @@ static const struct nla_policy ifla_policy[IFLA_MAX+1] = { [IFLA_PROMISCUITY] = { .type = NLA_U32 }, [IFLA_NUM_TX_QUEUES] = { .type = NLA_U32 }, [IFLA_NUM_RX_QUEUES] = { .type = NLA_U32 }, - [IFLA_PHYS_PORT_ID] = { .type = NLA_BINARY, .len = MAX_PHYS_PORT_ID_LEN }, + [IFLA_PHYS_PORT_ID] = { .type = NLA_BINARY, .len = MAX_PHYS_ITEM_ID_LEN }, [IFLA_CARRIER_CHANGES] = { .type = NLA_U32 }, /* ignored */ };
Signature · 1 line
1.9.0
A message that is not in the archive (sent off-list or not yet received): 1397736876-11771-3-git-send-email-jiri-rHqAuBHg3fBzbRFIqnYvSA@public.gmane.org
Re: [patch net-next RFC v3 02/10] net: rename netdev_phys_port_id to more generic name
Quoted 57 lines · On Thu, 17 Apr 2014 14:14:29 +0200 Jiri Pirko…
So this can be reused for identification of other "items" as well.
Signed-off-by Jiri Pirko <[email protected]>--- drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c | 2 +- drivers/net/ethernet/mellanox/mlx4/en_netdev.c | 2 +- drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c | 2 +- include/linux/netdevice.h | 16 ++++++++-------- net/core/dev.c | 2 +- net/core/net-sysfs.c | 2 +- net/core/rtnetlink.c | 6 +++--- 7 files changed, 16 insertions(+), 16 deletions(-)drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c +1
-1@@ -12360,7 +12360,7 @@ static int bnx2x_validate_addr(struct net_device *dev) }static int bnx2x_get_phys_port_id (struct net_device *netdev, -struct netdev_phys_port_id *ppid) +struct netdev_phys_item_id *ppid) {struct bnx2x *bp =netdev_priv (netdev);drivers/net/ethernet/mellanox/mlx4/en_netdev.c +1
-1@@ -2251,7 +2251,7 @@ static int mlx4_en_set_vf_link_state(struct net_device *dev, int vf, int link_st#define PORT_ID_BYTE_LEN 8static int mlx4_en_get_phys_port_id (struct net_device *dev, -struct netdev_phys_port_id *ppid) +struct netdev_phys_item_id *ppid) {struct mlx4_en_priv *priv =netdev_priv (dev);struct mlx4_dev *mdev = priv->mdev->dev;drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c +1
-1@@ -450,7 +450,7 @@ static void qlcnic_82xx_cancel_idc_work(struct qlcnic_adapter *adapter) }static int qlcnic_get_phys_port_id (struct net_device *netdev, -struct netdev_phys_port_id *ppid) +struct netdev_phys_item_id *ppid) {struct qlcnic_adapter *adapter =netdev_priv (netdev);struct qlcnic_hardware_context *ahw = adapter->ahw;include/linux/netdevice.h +0
-0
include/linux/netdevice.h struct netdev_fcoe_hbainfo { · line 739
Quoted 6 lines
include/linux/netdevice.h +1
-1@@ -735,13 +735,13 @@ struct netdev_fcoe_hbainfo { };#endif -#define MAX_PHYS_PORT_ID_LEN 32 +#define MAX_PHYS_ITEM_ID_LEN 32
Why the rename?
A message that is not in the archive (sent off-list or not yet received): 20140417080110.73485409-We1ePj4FEcvRI77zikRAJc56i+j3xesD0e7PPNI6Mm0@public.gmane.org
Re: [patch net-next RFC v3 02/10] net: rename netdev_phys_port_id to more generic name
Quoted 63 lines · Thu, Apr 17, 2014 at 05:01:10PM CEST, stephen-OTpzqLSitTUnbdJkjeBofR2eb7JE58TQ@…
Quoted 60 lines · On Thu, 17 Apr 2014 14:14:29 +0200 Jiri Pirko…
So this can be reused for identification of other "items" as well.
Signed-off-by Jiri Pirko <[email protected]>--- drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c | 2 +- drivers/net/ethernet/mellanox/mlx4/en_netdev.c | 2 +- drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c | 2 +- include/linux/netdevice.h | 16 ++++++++-------- net/core/dev.c | 2 +- net/core/net-sysfs.c | 2 +- net/core/rtnetlink.c | 6 +++--- 7 files changed, 16 insertions(+), 16 deletions(-)drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c +1
-1@@ -12360,7 +12360,7 @@ static int bnx2x_validate_addr(struct net_device *dev) }static int bnx2x_get_phys_port_id (struct net_device *netdev, -struct netdev_phys_port_id *ppid) +struct netdev_phys_item_id *ppid) {struct bnx2x *bp =netdev_priv (netdev);drivers/net/ethernet/mellanox/mlx4/en_netdev.c +1
-1@@ -2251,7 +2251,7 @@ static int mlx4_en_set_vf_link_state(struct net_device *dev, int vf, int link_st#define PORT_ID_BYTE_LEN 8static int mlx4_en_get_phys_port_id (struct net_device *dev, -struct netdev_phys_port_id *ppid) +struct netdev_phys_item_id *ppid) {struct mlx4_en_priv *priv =netdev_priv (dev);struct mlx4_dev *mdev = priv->mdev->dev;drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c +1
-1@@ -450,7 +450,7 @@ static void qlcnic_82xx_cancel_idc_work(struct qlcnic_adapter *adapter) }static int qlcnic_get_phys_port_id (struct net_device *netdev, -struct netdev_phys_port_id *ppid) +struct netdev_phys_item_id *ppid) {struct qlcnic_adapter *adapter =netdev_priv (netdev);struct qlcnic_hardware_context *ahw = adapter->ahw;include/linux/netdevice.h +0
-0@@ -735,13 +735,13 @@ struct netdev_fcoe_hbainfo { };#endif
Quoted 5 lines
include/linux/netdevice.h struct netdev_fcoe_hbainfo { · line 739
Quoted 3 lines
include/linux/netdevice.h +1
-1-#define MAX_PHYS_PORT_ID_LEN 32 +#define MAX_PHYS_ITEM_ID_LEN 32Why the rename?
I use the same struct in "net: introduce generic switch devices support" to identify switch. So that is no longer only a "port id"
RFC PATCH v3 3/10 net: introduce generic switch devices support
In reply to Jiri PirkoThe goal of this is to provide a possibility to suport various switch chips. Drivers should implement relevant ndos to do so. So far, only one ndo for getting physical switch id is in place.
--- Documentation/networking/switchdev.txt | 53 ++++++++++++++++++++++++++++++++++ include/linux/netdevice.h | 10 +++++++ include/linux/switchdev.h | 30 +++++++++++++++++++ net/Kconfig | 6 ++++ net/core/Makefile | 1 + net/core/switchdev.c | 32 ++++++++++++++++++++ 6 files changed, 132 insertions(+) create mode 100644 Documentation/networking/switchdev.txt create mode 100644 include/linux/switchdev.h create mode 100644 net/core/switchdev.c
Documentation/networking/switchdev.txt new file +53 -0
@@ -0,0 +1,53 @@ +Switch device drivers HOWTO +=========================== + +First lets describe a topology a bit. Imagine the following example: + + +----------------------------+ +---------------+ + | SOME switch chip | | CPU | + +----------------------------+ +---------------+ + port1 port2 port3 port4 MNGMNT | PCI-E | + | | | | | +---------------+ + PHY PHY | | | | NIC0 NIC1 + | | | | | | + | | +- PCI-E -+ | | + | +------- MII -------+ | + +------------- MII ------------+ + +In this example, there are two independent lines between the switch silicon +and CPU. NIC0 and NIC1 drivers are not aware of a switch presence. They are +separate from the switch driver. SOME switch chip is by managed by a driver +via PCI-E device MNGMNT. Note that MNGMNT device, NIC0 and NIC1 may be +connected to some other type of bus. + +Now, for the previous example show the representation in kernel: + + +----------------------------+ +---------------+ + | SOME switch chip | | CPU | + +----------------------------+ +---------------+ + sw0p0 sw0p1 sw0p2 sw0p3 MNGMNT | PCI-E | + | | | | | +---------------+ + PHY PHY | | | | eth0 eth1 + | | | | | | + | | +- PCI-E -+ | | + | +------- MII -------+ | + +------------- MII ------------+ + +Lets call the example switch driver for SOME switch chip "SOMEswitch". This +driver takes care of PCI-E device MNGMNT. There is a netdevice instance sw0pX +created for each port of a switch. These netdevices are instances +of "SOMEswitch" driver. sw0pX netdevices serve as a "representation" +of the switch chip. eth0 and eth1 are instances of some other existing driver. + +The only difference of the switch-port netdevice from the ordinary netdevice +is that is implements couple more NDOs: + + ndo_swdev_get_id - This returns the same ID for two port netdevices of + the same physical switch chip. This is mandatory to + be implemented by all switch drivers and serves + the caller for recognition of a port netdevice. + ndo_swdev_* - Functions that serve for a manipulation of the switch chip + itself. They are not port-specific. Caller might use + arbitrary port netdevice of the same switch and it will + make no difference. + ndo_swportdev_* - Functions that serve for a port-specific manipulation.
include/linux/netdevice.h +10 -0
@@ -991,6 +991,12 @@ typedef u16 (*select_queue_fallback_t)(struct net_device *dev,* Callback to use for xmit over the accelerated station. This * is used in place of ndo_start_xmit on accelerated net * devices. +* +* int (*ndo_swdev_get_id)(struct net_device *dev, +* struct netdev_phys_item_id *psid); +* Called to get an ID of the switch chip this port is part of. +* If driver implements this, it indicates that it represents a port +* of a switch chip. */ struct net_device_ops {int (*ndo_init)(struct net_device *dev);
@@ -1137,6 +1143,10 @@ struct net_device_ops {netdev_tx_t (*ndo_dfwd_start_xmit) (struct sk_buff *skb,struct net_device *dev,void *priv); +#ifdef CONFIG_NET_SWITCHDEV +int (*ndo_swdev_get_id)(struct net_device *dev, +struct netdev_phys_item_id *psid); +#endif };/**
include/linux/switchdev.h new file +30 -0
@@ -0,0 +1,30 @@ +/* +* include/linux/switchdev.h - Switch device API +* Copyright (c) 2014 Jiri Pirko <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +*/ +#ifndef _LINUX_SWITCHDEV_H_ +#define _LINUX_SWITCHDEV_H_ + +#include <linux/netdevice.h> +#include <linux/sw_flow.h> + +#ifdef CONFIG_NET_SWITCHDEV + +int swdev_get_id (struct net_device *dev,struct netdev_phys_item_id *psid); + +#else + +static inline int swdev_get_id (struct net_device *dev, +struct netdev_phys_item_id *psid) +{ +return -EOPNOTSUPP ; +} + +#endif + +#endif /* _LINUX_SWITCHDEV_H_ */
net/Kconfig +6 -0
@@ -289,6 +289,12 @@ config NET_FLOW_LIMIT with many clients some protection against DoS by a single (spoofed) flow that greatly exceeds average workload. +config NET_SWITCHDEV + boolean "Switch device support" + depends on INET + ---help--- + This module provides support for hardware switch chips. + menu "Network testing" config NET_PKTGEN
net/core/Makefile +1 -0
@@ -24,3 +24,4 @@ obj-$(CONFIG_NETWORK_PHY_TIMESTAMPING) += timestamping.o obj-$(CONFIG_NET_PTP_CLASSIFY) += ptp_classifier.o obj-$(CONFIG_CGROUP_NET_PRIO) += netprio_cgroup.o obj-$(CONFIG_CGROUP_NET_CLASSID) += netclassid_cgroup.o +obj-$(CONFIG_NET_SWITCHDEV) += switchdev.o
net/core/switchdev.c new file +32 -0
@@ -0,0 +1,32 @@ +/* +* net/core/switchdev.c - Switch device API +* Copyright (c) 2014 Jiri Pirko <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +*/ + +#include <linux/kernel.h> +#include <linux/types.h> +#include <linux/init.h> +#include <linux/netdevice.h> +#include <linux/switchdev.h> + +/** +* swdev_get_id - Get ID of a switch +* @dev: port device +* @psid: switch ID +* +* Get ID of a switch this port is part of. +*/ +int swdev_get_id (struct net_device *dev,struct netdev_phys_item_id *psid) +{ +const struct net_device_ops *ops = dev->netdev_ops; + +if (!ops->ndo_swdev_get_id) +return -EOPNOTSUPP ; +return ops->ndo_swdev_get_id (dev, psid); +} +EXPORT_SYMBOL (swdev_get_id);
Signature · 1 line
1.9.0
RFC PATCH v3 4/10 rtnl: expose physical switch id for particular device
In reply to Jiri PirkoThe the netdevice represents a port in a switch, it will expose IFLA_PHYS_SWITCH_ID value via rtnl. Two netdevices with a same value belong to one physical switch.
--- include/uapi/linux/if_link.h | 1 + net/core/rtnetlink.c | 26 +++++++++++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-)
include/uapi/linux/if_link.h +1 -0
@@ -145,6 +145,7 @@ enum {IFLA_CARRIER ,IFLA_PHYS_PORT_ID ,IFLA_CARRIER_CHANGES , +IFLA_PHYS_SWITCH_ID , __IFLA_MAX };
net/core/rtnetlink.c +25 -1
@@ -43,6 +43,7 @@#include <linux/inet.h> #include <linux/netdevice.h> +#include <linux/switchdev.h> #include <net/ip.h> #include <net/protocol.h> #include <net/arp.h>
@@ -829,7 +830,8 @@ static noinline size_t if_nlmsg_size(const struct net_device *dev, +rtnl_port_size (dev)/* IFLA_VF_PORTS + IFLA_PORT_SELF */ +rtnl_link_get_size (dev)/* IFLA_LINKINFO */ +rtnl_link_get_af_size (dev)/* IFLA_AF_SPEC */ - +nla_total_size (MAX_PHYS_ITEM_ID_LEN );/* IFLA_PHYS_PORT_ID */ + +nla_total_size (MAX_PHYS_ITEM_ID_LEN )/* IFLA_PHYS_PORT_ID */ + +nla_total_size (MAX_PHYS_ITEM_ID_LEN );/* IFLA_PHYS_SWITCH_ID */ }static int rtnl_vf_ports_fill (struct sk_buff *skb,struct net_device *dev)
@@ -926,6 +928,24 @@ static int rtnl_phys_port_id_fill(struct sk_buff *skb, struct net_device *dev)return 0 ; } +static int rtnl_phys_switch_id_fill (struct sk_buff *skb,struct net_device *dev) +{ +int err; +struct netdev_phys_item_id psid; + + err =swdev_get_id (dev, &psid); +if (err) { +if (err == -EOPNOTSUPP ) +return 0 ; +return err; + } + +if (nla_put (skb,IFLA_PHYS_SWITCH_ID , psid.id_len, psid.id)) +return -EMSGSIZE ; + +return 0 ; +} +static int rtnl_fill_ifinfo (struct sk_buff *skb,struct net_device *dev,int type,u32 pid,u32 seq,u32 change,unsigned int flags,u32 ext_filter_mask)
@@ -998,6 +1018,9 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb, struct net_device *dev,if (rtnl_phys_port_id_fill (skb, dev)) goto nla_put_failure; +if (rtnl_phys_switch_id_fill (skb, dev)) + goto nla_put_failure; + attr =nla_reserve (skb,IFLA_STATS ,sizeof (struct rtnl_link_stats ));if (attr ==NULL )
@@ -1151,6 +1174,7 @@ static const struct nla_policy ifla_policy[IFLA_MAX+1] = { [IFLA_NUM_RX_QUEUES] = { .type = NLA_U32 }, [IFLA_PHYS_PORT_ID] = { .type = NLA_BINARY, .len = MAX_PHYS_ITEM_ID_LEN }, [IFLA_CARRIER_CHANGES] = { .type = NLA_U32 }, /* ignored */ + [IFLA_PHYS_SWITCH_ID] = { .type = NLA_BINARY, .len = MAX_PHYS_ITEM_ID_LEN }, };static const struct nla_policy ifla_info_policy[IFLA_INFO_MAX +1 ] = {
Signature · 1 line
1.9.0
Re: [patch net-next RFC v3 04/10] rtnl: expose physical switch id for particular device
Quoted 1 line · Jiri Pirko
The the netdevice represents a port in a switch, it will expose
remove one 'the'
Quoted 1 line
IFLA_PHYS_SWITCH_IDvalue via rtnl. Two netdevices with a same value
s/a same/the same
Quoted 3 lines
belong to one physical switch.
Signed-off-by Jiri Pirko <[email protected]>
Quoted 89 lines
--- include/uapi/linux/if_link.h | 1 + net/core/rtnetlink.c | 26 +++++++++++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-)include/uapi/linux/if_link.h +1
-0@@ -145,6 +145,7 @@ enum {IFLA_CARRIER ,IFLA_PHYS_PORT_ID ,IFLA_CARRIER_CHANGES , +IFLA_PHYS_SWITCH_ID , __IFLA_MAX };net/core/rtnetlink.c +25
-2@@ -43,6 +43,7 @@#include <linux/inet.h> #include <linux/netdevice.h> +#include <linux/switchdev.h> #include <net/ip.h> #include <net/protocol.h> #include <net/arp.h> @@ -829,7 +830,8 @@ static noinline size_t if_nlmsg_size(const struct net_device *dev, +rtnl_port_size (dev)/* IFLA_VF_PORTS + IFLA_PORT_SELF */ +rtnl_link_get_size (dev)/* IFLA_LINKINFO */ +rtnl_link_get_af_size (dev)/* IFLA_AF_SPEC */ - +nla_total_size (MAX_PHYS_ITEM_ID_LEN );/* IFLA_PHYS_PORT_ID */ + +nla_total_size (MAX_PHYS_ITEM_ID_LEN )/* IFLA_PHYS_PORT_ID */ + +nla_total_size (MAX_PHYS_ITEM_ID_LEN );/* IFLA_PHYS_SWITCH_ID */ }static int rtnl_vf_ports_fill (struct sk_buff *skb,struct net_device *dev)@@ -926,6 +928,24 @@ static int rtnl_phys_port_id_fill(struct sk_buff *skb, struct net_device *dev)return 0 ; } +static int rtnl_phys_switch_id_fill (struct sk_buff *skb,struct net_device *dev) +{ +int err; +struct netdev_phys_item_id psid; + + err =swdev_get_id (dev, &psid); +if (err) { +if (err == -EOPNOTSUPP ) +return 0 ; +return err; + } + +if (nla_put (skb,IFLA_PHYS_SWITCH_ID , psid.id_len, psid.id)) +return -EMSGSIZE ; + +return 0 ; +} +static int rtnl_fill_ifinfo (struct sk_buff *skb,struct net_device *dev,int type,u32 pid,u32 seq,u32 change,unsigned int flags,u32 ext_filter_mask)@@ -998,6 +1018,9 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb, struct net_device *dev,if (rtnl_phys_port_id_fill (skb, dev)) goto nla_put_failure; +if (rtnl_phys_switch_id_fill (skb, dev)) + goto nla_put_failure; + attr =nla_reserve (skb,IFLA_STATS ,sizeof (struct rtnl_link_stats ));if (attr ==NULL )@@ -1151,6 +1174,7 @@ static const struct nla_policy ifla_policy[IFLA_MAX+1] = { [IFLA_NUM_RX_QUEUES] = { .type = NLA_U32 }, [IFLA_PHYS_PORT_ID] = { .type = NLA_BINARY, .len = MAX_PHYS_ITEM_ID_LEN }, [IFLA_CARRIER_CHANGES] = { .type = NLA_U32 }, /* ignored */ + [IFLA_PHYS_SWITCH_ID] = { .type = NLA_BINARY, .len = MAX_PHYS_ITEM_ID_LEN }, };static const struct nla_policy ifla_info_policy[IFLA_INFO_MAX +1 ] = { --1.9.0
--
To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
RFC PATCH v3 5/10 switchdev: introduce basic support for flows
In reply to Jiri PirkoThis patch adds a couple of ndos which can be used to work with flows. Note that user can use random port netdevice to access the switch.
--- include/linux/netdevice.h | 30 ++++++++++++++++++++++++ include/linux/switchdev.h | 25 ++++++++++++++++++++ net/core/switchdev.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 113 insertions(+)
include/linux/netdevice.h +30 -0
@@ -49,6 +49,8 @@#include <linux/netdev_features.h> #include <linux/neighbour.h> +#include <linux/sw_flow.h> +#include <uapi/linux/netdevice.h> struct netpoll_info ;
@@ -997,6 +999,26 @@ typedef u16 (*select_queue_fallback_t)(struct net_device *dev,* Called to get an ID of the switch chip this port is part of. * If driver implements this, it indicates that it represents a port * of a switch chip. +* +* int (*ndo_swdev_flow_insert)(struct net_device *dev, +* const struct sw_flow *flow); +* Called to insert a flow into switch device. If driver does +* not implement this, it is assumed that the hw does not have +* a capability to work with flows. +* +* int (*ndo_swdev_flow_remove)(struct net_device *dev, +* const struct sw_flow *flow); +* Called to remove a flow from switch device. If driver does +* not implement this, it is assumed that the hw does not have +* a capability to work with flows. +* +* int (*ndo_swdev_flow_action_set)(struct net_device *dev, +* const struct sw_flow *flow, +* const struct sw_flow_action *action, +* size_t action_count); +* Called to set actions for a flow inserted in swtich device. +* If driver does not implement this, it is assumed that the hw does +* not have a capability to work with flows. */ struct net_device_ops {int (*ndo_init)(struct net_device *dev);
@@ -1146,6 +1168,14 @@ struct net_device_ops {#ifdef CONFIG_NET_SWITCHDEV int (*ndo_swdev_get_id)(struct net_device *dev,struct netdev_phys_item_id *psid); +int (*ndo_swdev_flow_insert)(struct net_device *dev, +const struct sw_flow *flow); +int (*ndo_swdev_flow_remove)(struct net_device *dev, +const struct sw_flow *flow); +int (*ndo_swdev_flow_action_set)(struct net_device *dev, +const struct sw_flow *flow, +const struct sw_flow_action *action, +size_t action_count);#endif };
include/linux/switchdev.h +25 -0
@@ -16,6 +16,11 @@#ifdef CONFIG_NET_SWITCHDEV int swdev_get_id (struct net_device *dev,struct netdev_phys_item_id *psid); +int swdev_flow_insert (struct net_device *dev,const struct sw_flow *flow); +int swdev_flow_remove (struct net_device *dev,const struct sw_flow *flow); +int swdev_flow_action_set (struct net_device *dev,const struct sw_flow *flow, +const struct sw_flow_action *action, +size_t action_count);#else
@@ -25,6 +30,26 @@ static inline int swdev_get_id(struct net_device *dev,return -EOPNOTSUPP ; } +static inline int swdev_flow_insert (struct net_device *dev, +const struct sw_flow *flow) +{ +return -EOPNOTSUPP ; +} + +static inline int swdev_flow_remove (struct net_device *dev, +const struct sw_flow *flow) +{ +return -EOPNOTSUPP ; +} + +static inline int swdev_flow_action_set (struct net_device *dev, +const struct sw_flow *flow, +const struct sw_flow_action *action, +size_t action_count) +{ +return -EOPNOTSUPP ; +} +#endif #endif /* _LINUX_SWITCHDEV_H_ */
net/core/switchdev.c +58 -0
61 lines not on this page · raw message
Signature · 1 line
1.9.0
RFC PATCH v3 7/10 dsa: implement ndo_swdev_get_id
In reply to Jiri Pirko--- net/dsa/slave.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
net/dsa/slave.c +16 -0
@@ -171,6 +171,19 @@ static int dsa_slave_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)return -EOPNOTSUPP ; } +static int dsa_slave_swdev_get_id (struct net_device *dev, +struct netdev_phys_item_id *psid) +{ +struct dsa_slave_priv *p =netdev_priv (dev); +struct dsa_switch *ds = p->parent; +u64 tmp = (u64 ) ds; + +/* TODO: add more sophisticated id generation */ +memcpy (&psid->id, &tmp,sizeof (tmp)); + psid->id_len =sizeof (tmp); + +return 0 ; +}/* ethtool operations *******************************************************/ static int
@@ -303,6 +316,7 @@ static const struct net_device_ops dsa_netdev_ops = { .ndo_set_rx_mode = dsa_slave_set_rx_mode, .ndo_set_mac_address = dsa_slave_set_mac_address, .ndo_do_ioctl = dsa_slave_ioctl, + .ndo_swdev_get_id = dsa_slave_swdev_get_id, };#endif #ifdef CONFIG_NET_DSA_TAG_EDSA
@@ -315,6 +329,7 @@ static const struct net_device_ops edsa_netdev_ops = { .ndo_set_rx_mode = dsa_slave_set_rx_mode, .ndo_set_mac_address = dsa_slave_set_mac_address, .ndo_do_ioctl = dsa_slave_ioctl, + .ndo_swdev_get_id = dsa_slave_swdev_get_id, };#endif #ifdef CONFIG_NET_DSA_TAG_TRAILER
@@ -327,6 +342,7 @@ static const struct net_device_ops trailer_netdev_ops = { .ndo_set_rx_mode = dsa_slave_set_rx_mode, .ndo_set_mac_address = dsa_slave_set_mac_address, .ndo_do_ioctl = dsa_slave_ioctl, + .ndo_swdev_get_id = dsa_slave_swdev_get_id, };#endif
Signature · 1 line
1.9.0
RFC PATCH v3 9/10 openvswitch: introduce vport_op get_netdev
In reply to Jiri PirkoThis will allow to query easily if the vport has netdev. Also it allows to unexpose netdev_vport_priv and struct netdev_vport.
--- net/openvswitch/datapath.c | 2 +- net/openvswitch/dp_notify.c | 7 ++--- net/openvswitch/vport-internal_dev.c | 53 ++++++++++++++++++++++++------------ net/openvswitch/vport-netdev.c | 16 +++++++++++ net/openvswitch/vport-netdev.h | 12 -------- net/openvswitch/vport.h | 2 ++ 6 files changed, 57 insertions(+), 35 deletions(-)
net/openvswitch/datapath.c +1 -1
@@ -148,7 +148,7 @@ static int get_dpifindex(struct datapath *dp) local =ovs_vport_rcu (dp,OVSP_LOCAL );if (local) - ifindex =netdev_vport_priv (local)->dev->ifindex; + ifindex = local->ops->get_netdev (local)->ifindex;else ifindex =0 ;
net/openvswitch/dp_notify.c +3 -4
@@ -58,13 +58,12 @@ void ovs_dp_notify_wq(struct work_struct *work)struct hlist_node *n;hlist_for_each_entry_safe (vport, n, &dp->ports[i], dp_hash_node) { -struct netdev_vport *netdev_vport; +struct net_device *dev;if (vport->ops->type !=OVS_VPORT_TYPE_NETDEV )continue ; - - netdev_vport =netdev_vport_priv (vport); -if (!(netdev_vport->dev->priv_flags &IFF_OVS_DATAPATH )) + dev = vport->ops->get_netdev (vport); +if (!(dev->priv_flags &IFF_OVS_DATAPATH ))dp_detach_port_notify (vport); } }
net/openvswitch/vport-internal_dev.c +35 -18
122 lines not on this page · raw message
net/openvswitch/vport-netdev.c +16 -0
@@ -33,6 +33,16 @@#include "vport-internal_dev.h" #include "vport-netdev.h" +struct netdev_vport { +struct rcu_head rcu; +struct net_device *dev; +}; + +static struct netdev_vport *netdev_vport_priv (const struct vport *vport) +{ +return vport_priv (vport); +} +/* Must be called with rcu_read_lock. */ static void netdev_port_receive (struct vport *vport,struct sk_buff *skb) {
@@ -224,10 +234,16 @@ struct vport *ovs_netdev_get_vport(struct net_device *dev)return NULL ; } +static struct net_device *netdev_get_netdev (struct vport *vport) +{ +return netdev_vport_priv (vport)->dev; +} +const struct vport_ops ovs_netdev_vport_ops = { .type =OVS_VPORT_TYPE_NETDEV , .create = netdev_create, .destroy = netdev_destroy, .get_name = ovs_netdev_get_name, .send = netdev_send, + .get_netdev = netdev_get_netdev, };
net/openvswitch/vport-netdev.h +0 -12
@@ -26,18 +26,6 @@struct vport *ovs_netdev_get_vport (struct net_device *dev); -struct netdev_vport { -struct rcu_head rcu; - -struct net_device *dev; -}; - -static inline struct netdev_vport * -netdev_vport_priv (const struct vport *vport) -{ -return vport_priv (vport); -} -const char *ovs_netdev_get_name (const struct vport *);void ovs_netdev_detach_dev (struct vport *);
net/openvswitch/vport.h +2 -0
@@ -145,6 +145,8 @@ struct vport_ops {const char *(*get_name)(const struct vport *);int (*send)(struct vport *,struct sk_buff *); + +struct net_device *(*get_netdev)(struct vport *); };enum vport_err_type {
Signature · 1 line
1.9.0