diff options
Diffstat (limited to 'net/openvswitch/datapath.h')
-rw-r--r-- | net/openvswitch/datapath.h | 52 |
1 files changed, 43 insertions, 9 deletions
diff --git a/net/openvswitch/datapath.h b/net/openvswitch/datapath.h index c1105c147531..031dfbf37c93 100644 --- a/net/openvswitch/datapath.h +++ b/net/openvswitch/datapath.h | |||
@@ -27,10 +27,11 @@ | |||
27 | #include <linux/u64_stats_sync.h> | 27 | #include <linux/u64_stats_sync.h> |
28 | 28 | ||
29 | #include "flow.h" | 29 | #include "flow.h" |
30 | #include "vport.h" | ||
30 | 31 | ||
31 | struct vport; | 32 | #define DP_MAX_PORTS USHRT_MAX |
33 | #define DP_VPORT_HASH_BUCKETS 1024 | ||
32 | 34 | ||
33 | #define DP_MAX_PORTS 1024 | ||
34 | #define SAMPLE_ACTION_DEPTH 3 | 35 | #define SAMPLE_ACTION_DEPTH 3 |
35 | 36 | ||
36 | /** | 37 | /** |
@@ -58,11 +59,10 @@ struct dp_stats_percpu { | |||
58 | * @list_node: Element in global 'dps' list. | 59 | * @list_node: Element in global 'dps' list. |
59 | * @n_flows: Number of flows currently in flow table. | 60 | * @n_flows: Number of flows currently in flow table. |
60 | * @table: Current flow table. Protected by genl_lock and RCU. | 61 | * @table: Current flow table. Protected by genl_lock and RCU. |
61 | * @ports: Map from port number to &struct vport. %OVSP_LOCAL port | 62 | * @ports: Hash table for ports. %OVSP_LOCAL port always exists. Protected by |
62 | * always exists, other ports may be %NULL. Protected by RTNL and RCU. | 63 | * RTNL and RCU. |
63 | * @port_list: List of all ports in @ports in arbitrary order. RTNL required | ||
64 | * to iterate or modify. | ||
65 | * @stats_percpu: Per-CPU datapath statistics. | 64 | * @stats_percpu: Per-CPU datapath statistics. |
65 | * @net: Reference to net namespace. | ||
66 | * | 66 | * |
67 | * Context: See the comment on locking at the top of datapath.c for additional | 67 | * Context: See the comment on locking at the top of datapath.c for additional |
68 | * locking information. | 68 | * locking information. |
@@ -75,13 +75,37 @@ struct datapath { | |||
75 | struct flow_table __rcu *table; | 75 | struct flow_table __rcu *table; |
76 | 76 | ||
77 | /* Switch ports. */ | 77 | /* Switch ports. */ |
78 | struct vport __rcu *ports[DP_MAX_PORTS]; | 78 | struct hlist_head *ports; |
79 | struct list_head port_list; | ||
80 | 79 | ||
81 | /* Stats. */ | 80 | /* Stats. */ |
82 | struct dp_stats_percpu __percpu *stats_percpu; | 81 | struct dp_stats_percpu __percpu *stats_percpu; |
82 | |||
83 | #ifdef CONFIG_NET_NS | ||
84 | /* Network namespace ref. */ | ||
85 | struct net *net; | ||
86 | #endif | ||
83 | }; | 87 | }; |
84 | 88 | ||
89 | struct vport *ovs_lookup_vport(const struct datapath *dp, u16 port_no); | ||
90 | |||
91 | static inline struct vport *ovs_vport_rcu(const struct datapath *dp, int port_no) | ||
92 | { | ||
93 | WARN_ON_ONCE(!rcu_read_lock_held()); | ||
94 | return ovs_lookup_vport(dp, port_no); | ||
95 | } | ||
96 | |||
97 | static inline struct vport *ovs_vport_rtnl_rcu(const struct datapath *dp, int port_no) | ||
98 | { | ||
99 | WARN_ON_ONCE(!rcu_read_lock_held() && !rtnl_is_locked()); | ||
100 | return ovs_lookup_vport(dp, port_no); | ||
101 | } | ||
102 | |||
103 | static inline struct vport *ovs_vport_rtnl(const struct datapath *dp, int port_no) | ||
104 | { | ||
105 | ASSERT_RTNL(); | ||
106 | return ovs_lookup_vport(dp, port_no); | ||
107 | } | ||
108 | |||
85 | /** | 109 | /** |
86 | * struct ovs_skb_cb - OVS data in skb CB | 110 | * struct ovs_skb_cb - OVS data in skb CB |
87 | * @flow: The flow associated with this packet. May be %NULL if no flow. | 111 | * @flow: The flow associated with this packet. May be %NULL if no flow. |
@@ -105,9 +129,19 @@ struct dp_upcall_info { | |||
105 | u8 cmd; | 129 | u8 cmd; |
106 | const struct sw_flow_key *key; | 130 | const struct sw_flow_key *key; |
107 | const struct nlattr *userdata; | 131 | const struct nlattr *userdata; |
108 | u32 pid; | 132 | u32 portid; |
109 | }; | 133 | }; |
110 | 134 | ||
135 | static inline struct net *ovs_dp_get_net(struct datapath *dp) | ||
136 | { | ||
137 | return read_pnet(&dp->net); | ||
138 | } | ||
139 | |||
140 | static inline void ovs_dp_set_net(struct datapath *dp, struct net *net) | ||
141 | { | ||
142 | write_pnet(&dp->net, net); | ||
143 | } | ||
144 | |||
111 | extern struct notifier_block ovs_dp_device_notifier; | 145 | extern struct notifier_block ovs_dp_device_notifier; |
112 | extern struct genl_multicast_group ovs_dp_vport_multicast_group; | 146 | extern struct genl_multicast_group ovs_dp_vport_multicast_group; |
113 | 147 | ||