aboutsummaryrefslogtreecommitdiffstats
path: root/net/openvswitch/vport.c
diff options
context:
space:
mode:
authorPravin B Shelar <pshelar@nicira.com>2013-04-15 16:30:37 -0400
committerJesse Gross <jesse@nicira.com>2013-04-15 17:56:25 -0400
commite0f0ecf33c3f13401f90bff5afdc3ed1bb40b9af (patch)
tree128ce5d78983ae8df32a70a3fd4344ab5216448d /net/openvswitch/vport.c
parent8e4e1713e4978447c5f799aa668dcc6d2cb0dee9 (diff)
openvswitch: Use generic struct pcpu_tstats.
Rather than defining ovs specific stats struct (vport_percpu_stats), we can use existing pcpu_tstats to achieve exactly same functionality. Signed-off-by: Pravin B Shelar <pshelar@nicira.com> Signed-off-by: Jesse Gross <jesse@nicira.com>
Diffstat (limited to 'net/openvswitch/vport.c')
-rw-r--r--net/openvswitch/vport.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/net/openvswitch/vport.c b/net/openvswitch/vport.c
index c90d856d441c..720623190eaa 100644
--- a/net/openvswitch/vport.c
+++ b/net/openvswitch/vport.c
@@ -128,7 +128,7 @@ struct vport *ovs_vport_alloc(int priv_size, const struct vport_ops *ops,
128 vport->ops = ops; 128 vport->ops = ops;
129 INIT_HLIST_NODE(&vport->dp_hash_node); 129 INIT_HLIST_NODE(&vport->dp_hash_node);
130 130
131 vport->percpu_stats = alloc_percpu(struct vport_percpu_stats); 131 vport->percpu_stats = alloc_percpu(struct pcpu_tstats);
132 if (!vport->percpu_stats) { 132 if (!vport->percpu_stats) {
133 kfree(vport); 133 kfree(vport);
134 return ERR_PTR(-ENOMEM); 134 return ERR_PTR(-ENOMEM);
@@ -260,16 +260,16 @@ void ovs_vport_get_stats(struct vport *vport, struct ovs_vport_stats *stats)
260 spin_unlock_bh(&vport->stats_lock); 260 spin_unlock_bh(&vport->stats_lock);
261 261
262 for_each_possible_cpu(i) { 262 for_each_possible_cpu(i) {
263 const struct vport_percpu_stats *percpu_stats; 263 const struct pcpu_tstats *percpu_stats;
264 struct vport_percpu_stats local_stats; 264 struct pcpu_tstats local_stats;
265 unsigned int start; 265 unsigned int start;
266 266
267 percpu_stats = per_cpu_ptr(vport->percpu_stats, i); 267 percpu_stats = per_cpu_ptr(vport->percpu_stats, i);
268 268
269 do { 269 do {
270 start = u64_stats_fetch_begin_bh(&percpu_stats->sync); 270 start = u64_stats_fetch_begin_bh(&percpu_stats->syncp);
271 local_stats = *percpu_stats; 271 local_stats = *percpu_stats;
272 } while (u64_stats_fetch_retry_bh(&percpu_stats->sync, start)); 272 } while (u64_stats_fetch_retry_bh(&percpu_stats->syncp, start));
273 273
274 stats->rx_bytes += local_stats.rx_bytes; 274 stats->rx_bytes += local_stats.rx_bytes;
275 stats->rx_packets += local_stats.rx_packets; 275 stats->rx_packets += local_stats.rx_packets;
@@ -327,13 +327,13 @@ int ovs_vport_get_options(const struct vport *vport, struct sk_buff *skb)
327 */ 327 */
328void ovs_vport_receive(struct vport *vport, struct sk_buff *skb) 328void ovs_vport_receive(struct vport *vport, struct sk_buff *skb)
329{ 329{
330 struct vport_percpu_stats *stats; 330 struct pcpu_tstats *stats;
331 331
332 stats = this_cpu_ptr(vport->percpu_stats); 332 stats = this_cpu_ptr(vport->percpu_stats);
333 u64_stats_update_begin(&stats->sync); 333 u64_stats_update_begin(&stats->syncp);
334 stats->rx_packets++; 334 stats->rx_packets++;
335 stats->rx_bytes += skb->len; 335 stats->rx_bytes += skb->len;
336 u64_stats_update_end(&stats->sync); 336 u64_stats_update_end(&stats->syncp);
337 337
338 ovs_dp_process_received_packet(vport, skb); 338 ovs_dp_process_received_packet(vport, skb);
339} 339}
@@ -352,14 +352,14 @@ int ovs_vport_send(struct vport *vport, struct sk_buff *skb)
352 int sent = vport->ops->send(vport, skb); 352 int sent = vport->ops->send(vport, skb);
353 353
354 if (likely(sent)) { 354 if (likely(sent)) {
355 struct vport_percpu_stats *stats; 355 struct pcpu_tstats *stats;
356 356
357 stats = this_cpu_ptr(vport->percpu_stats); 357 stats = this_cpu_ptr(vport->percpu_stats);
358 358
359 u64_stats_update_begin(&stats->sync); 359 u64_stats_update_begin(&stats->syncp);
360 stats->tx_packets++; 360 stats->tx_packets++;
361 stats->tx_bytes += sent; 361 stats->tx_bytes += sent;
362 u64_stats_update_end(&stats->sync); 362 u64_stats_update_end(&stats->syncp);
363 } 363 }
364 return sent; 364 return sent;
365} 365}