datapath: Convert ODP_VPORT_* to use AF_NETLINK socket layer.
[sliver-openvswitch.git] / datapath / vport.c
1 /*
2  * Copyright (c) 2010, 2011 Nicira Networks.
3  * Distributed under the terms of the GNU GPL version 2.
4  *
5  * Significant portions of this file may be copied from parts of the Linux
6  * kernel, by Linus Torvalds and others.
7  */
8
9 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
10
11 #include <linux/dcache.h>
12 #include <linux/etherdevice.h>
13 #include <linux/if.h>
14 #include <linux/if_vlan.h>
15 #include <linux/kernel.h>
16 #include <linux/list.h>
17 #include <linux/mutex.h>
18 #include <linux/percpu.h>
19 #include <linux/rcupdate.h>
20 #include <linux/rtnetlink.h>
21 #include <linux/compat.h>
22 #include <linux/version.h>
23
24 #include "vport.h"
25 #include "vport-internal_dev.h"
26
27 /* List of statically compiled vport implementations.  Don't forget to also
28  * add yours to the list at the bottom of vport.h. */
29 static const struct vport_ops *base_vport_ops_list[] = {
30         &netdev_vport_ops,
31         &internal_vport_ops,
32         &patch_vport_ops,
33         &gre_vport_ops,
34 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26)
35         &capwap_vport_ops,
36 #endif
37 };
38
39 static const struct vport_ops **vport_ops_list;
40 static int n_vport_types;
41
42 /* Protected by RCU read lock for reading, RTNL lock for writing. */
43 static struct hlist_head *dev_table;
44 #define VPORT_HASH_BUCKETS 1024
45
46 /**
47  *      vport_init - initialize vport subsystem
48  *
49  * Called at module load time to initialize the vport subsystem and any
50  * compiled in vport types.
51  */
52 int vport_init(void)
53 {
54         int err;
55         int i;
56
57         dev_table = kzalloc(VPORT_HASH_BUCKETS * sizeof(struct hlist_head),
58                             GFP_KERNEL);
59         if (!dev_table) {
60                 err = -ENOMEM;
61                 goto error;
62         }
63
64         vport_ops_list = kmalloc(ARRAY_SIZE(base_vport_ops_list) *
65                                  sizeof(struct vport_ops *), GFP_KERNEL);
66         if (!vport_ops_list) {
67                 err = -ENOMEM;
68                 goto error_dev_table;
69         }
70
71         for (i = 0; i < ARRAY_SIZE(base_vport_ops_list); i++) {
72                 const struct vport_ops *new_ops = base_vport_ops_list[i];
73
74                 if (new_ops->init)
75                         err = new_ops->init();
76                 else
77                         err = 0;
78
79                 if (!err)
80                         vport_ops_list[n_vport_types++] = new_ops;
81                 else if (new_ops->flags & VPORT_F_REQUIRED) {
82                         vport_exit();
83                         goto error;
84                 }
85         }
86
87         return 0;
88
89 error_dev_table:
90         kfree(dev_table);
91 error:
92         return err;
93 }
94
95 /**
96  *      vport_exit - shutdown vport subsystem
97  *
98  * Called at module exit time to shutdown the vport subsystem and any
99  * initialized vport types.
100  */
101 void vport_exit(void)
102 {
103         int i;
104
105         for (i = 0; i < n_vport_types; i++) {
106                 if (vport_ops_list[i]->exit)
107                         vport_ops_list[i]->exit();
108         }
109
110         kfree(vport_ops_list);
111         kfree(dev_table);
112 }
113
114 static struct hlist_head *hash_bucket(const char *name)
115 {
116         unsigned int hash = full_name_hash(name, strlen(name));
117         return &dev_table[hash & (VPORT_HASH_BUCKETS - 1)];
118 }
119
120 /**
121  *      vport_locate - find a port that has already been created
122  *
123  * @name: name of port to find
124  *
125  * Must be called with RTNL or RCU read lock.
126  */
127 struct vport *vport_locate(const char *name)
128 {
129         struct hlist_head *bucket = hash_bucket(name);
130         struct vport *vport;
131         struct hlist_node *node;
132
133         hlist_for_each_entry_rcu(vport, node, bucket, hash_node)
134                 if (!strcmp(name, vport_get_name(vport)))
135                         return vport;
136
137         return NULL;
138 }
139
140 static void release_vport(struct kobject *kobj)
141 {
142         struct vport *p = container_of(kobj, struct vport, kobj);
143         kfree(p);
144 }
145
146 static struct kobj_type brport_ktype = {
147 #ifdef CONFIG_SYSFS
148         .sysfs_ops = &brport_sysfs_ops,
149 #endif
150         .release = release_vport
151 };
152
153 /**
154  *      vport_alloc - allocate and initialize new vport
155  *
156  * @priv_size: Size of private data area to allocate.
157  * @ops: vport device ops
158  *
159  * Allocate and initialize a new vport defined by @ops.  The vport will contain
160  * a private data area of size @priv_size that can be accessed using
161  * vport_priv().  vports that are no longer needed should be released with
162  * vport_free().
163  */
164 struct vport *vport_alloc(int priv_size, const struct vport_ops *ops, const struct vport_parms *parms)
165 {
166         struct vport *vport;
167         size_t alloc_size;
168
169         alloc_size = sizeof(struct vport);
170         if (priv_size) {
171                 alloc_size = ALIGN(alloc_size, VPORT_ALIGN);
172                 alloc_size += priv_size;
173         }
174
175         vport = kzalloc(alloc_size, GFP_KERNEL);
176         if (!vport)
177                 return ERR_PTR(-ENOMEM);
178
179         vport->dp = parms->dp;
180         vport->port_no = parms->port_no;
181         atomic_set(&vport->sflow_pool, 0);
182         vport->ops = ops;
183
184         /* Initialize kobject for bridge.  This will be added as
185          * /sys/class/net/<devname>/brport later, if sysfs is enabled. */
186         vport->kobj.kset = NULL;
187         kobject_init(&vport->kobj, &brport_ktype);
188
189         if (vport->ops->flags & VPORT_F_GEN_STATS) {
190                 vport->percpu_stats = alloc_percpu(struct vport_percpu_stats);
191                 if (!vport->percpu_stats)
192                         return ERR_PTR(-ENOMEM);
193
194                 spin_lock_init(&vport->stats_lock);
195         }
196
197         return vport;
198 }
199
200 /**
201  *      vport_free - uninitialize and free vport
202  *
203  * @vport: vport to free
204  *
205  * Frees a vport allocated with vport_alloc() when it is no longer needed.
206  *
207  * The caller must ensure that an RCU grace period has passed since the last
208  * time @vport was in a datapath.
209  */
210 void vport_free(struct vport *vport)
211 {
212         if (vport->ops->flags & VPORT_F_GEN_STATS)
213                 free_percpu(vport->percpu_stats);
214
215         kobject_put(&vport->kobj);
216 }
217
218 /**
219  *      vport_add - add vport device (for kernel callers)
220  *
221  * @parms: Information about new vport.
222  *
223  * Creates a new vport with the specified configuration (which is dependent on
224  * device type) and attaches it to a datapath.  RTNL lock must be held.
225  */
226 struct vport *vport_add(const struct vport_parms *parms)
227 {
228         struct vport *vport;
229         int err = 0;
230         int i;
231
232         ASSERT_RTNL();
233
234         for (i = 0; i < n_vport_types; i++) {
235                 if (vport_ops_list[i]->type == parms->type) {
236                         vport = vport_ops_list[i]->create(parms);
237                         if (IS_ERR(vport)) {
238                                 err = PTR_ERR(vport);
239                                 goto out;
240                         }
241
242                         hlist_add_head_rcu(&vport->hash_node,
243                                            hash_bucket(vport_get_name(vport)));
244                         return vport;
245                 }
246         }
247
248         err = -EAFNOSUPPORT;
249
250 out:
251         return ERR_PTR(err);
252 }
253
254 /**
255  *      vport_set_options - modify existing vport device (for kernel callers)
256  *
257  * @vport: vport to modify.
258  * @port: New configuration.
259  *
260  * Modifies an existing device with the specified configuration (which is
261  * dependent on device type).  RTNL lock must be held.
262  */
263 int vport_set_options(struct vport *vport, struct nlattr *options)
264 {
265         ASSERT_RTNL();
266
267         if (!vport->ops->set_options)
268                 return -EOPNOTSUPP;
269         return vport->ops->set_options(vport, options);
270 }
271
272 /**
273  *      vport_del - delete existing vport device
274  *
275  * @vport: vport to delete.
276  *
277  * Detaches @vport from its datapath and destroys it.  It is possible to fail
278  * for reasons such as lack of memory.  RTNL lock must be held.
279  */
280 int vport_del(struct vport *vport)
281 {
282         ASSERT_RTNL();
283
284         hlist_del_rcu(&vport->hash_node);
285
286         return vport->ops->destroy(vport);
287 }
288
289 /**
290  *      vport_set_mtu - set device MTU (for kernel callers)
291  *
292  * @vport: vport on which to set MTU.
293  * @mtu: New MTU.
294  *
295  * Sets the MTU of the given device.  Some devices may not support setting the
296  * MTU, in which case the result will always be -EOPNOTSUPP.  RTNL lock must
297  * be held.
298  */
299 int vport_set_mtu(struct vport *vport, int mtu)
300 {
301         ASSERT_RTNL();
302
303         if (mtu < 68)
304                 return -EINVAL;
305
306         if (vport->ops->set_mtu) {
307                 int ret;
308
309                 ret = vport->ops->set_mtu(vport, mtu);
310
311                 if (!ret && !is_internal_vport(vport))
312                         set_internal_devs_mtu(vport->dp);
313
314                 return ret;
315         } else
316                 return -EOPNOTSUPP;
317 }
318
319 /**
320  *      vport_set_addr - set device Ethernet address (for kernel callers)
321  *
322  * @vport: vport on which to set Ethernet address.
323  * @addr: New address.
324  *
325  * Sets the Ethernet address of the given device.  Some devices may not support
326  * setting the Ethernet address, in which case the result will always be
327  * -EOPNOTSUPP.  RTNL lock must be held.
328  */
329 int vport_set_addr(struct vport *vport, const unsigned char *addr)
330 {
331         ASSERT_RTNL();
332
333         if (!is_valid_ether_addr(addr))
334                 return -EADDRNOTAVAIL;
335
336         if (vport->ops->set_addr)
337                 return vport->ops->set_addr(vport, addr);
338         else
339                 return -EOPNOTSUPP;
340 }
341
342 /**
343  *      vport_set_stats - sets offset device stats
344  *
345  * @vport: vport on which to set stats
346  * @stats: stats to set
347  *
348  * Provides a set of transmit, receive, and error stats to be added as an
349  * offset to the collect data when stats are retreived.  Some devices may not
350  * support setting the stats, in which case the result will always be
351  * -EOPNOTSUPP.
352  *
353  * Must be called with RTNL lock.
354  */
355 int vport_set_stats(struct vport *vport, struct rtnl_link_stats64 *stats)
356 {
357         ASSERT_RTNL();
358
359         if (vport->ops->flags & VPORT_F_GEN_STATS) {
360                 spin_lock_bh(&vport->stats_lock);
361                 vport->offset_stats = *stats;
362                 spin_unlock_bh(&vport->stats_lock);
363
364                 return 0;
365         } else
366                 return -EOPNOTSUPP;
367 }
368
369 /**
370  *      vport_get_name - retrieve device name
371  *
372  * @vport: vport from which to retrieve the name.
373  *
374  * Retrieves the name of the given device.  Either RTNL lock or rcu_read_lock
375  * must be held for the entire duration that the name is in use.
376  */
377 const char *vport_get_name(const struct vport *vport)
378 {
379         return vport->ops->get_name(vport);
380 }
381
382 /**
383  *      vport_get_type - retrieve device type
384  *
385  * @vport: vport from which to retrieve the type.
386  *
387  * Retrieves the type of the given device.
388  */
389 enum odp_vport_type vport_get_type(const struct vport *vport)
390 {
391         return vport->ops->type;
392 }
393
394 /**
395  *      vport_get_addr - retrieve device Ethernet address (for kernel callers)
396  *
397  * @vport: vport from which to retrieve the Ethernet address.
398  *
399  * Retrieves the Ethernet address of the given device.  Either RTNL lock or
400  * rcu_read_lock must be held for the entire duration that the Ethernet address
401  * is in use.
402  */
403 const unsigned char *vport_get_addr(const struct vport *vport)
404 {
405         return vport->ops->get_addr(vport);
406 }
407
408 /**
409  *      vport_get_kobj - retrieve associated kobj
410  *
411  * @vport: vport from which to retrieve the associated kobj
412  *
413  * Retrieves the associated kobj or null if no kobj.  The returned kobj is
414  * valid for as long as the vport exists.
415  */
416 struct kobject *vport_get_kobj(const struct vport *vport)
417 {
418         if (vport->ops->get_kobj)
419                 return vport->ops->get_kobj(vport);
420         else
421                 return NULL;
422 }
423
424 static int vport_call_get_stats(struct vport *vport, struct rtnl_link_stats64 *stats)
425 {
426         int err;
427
428         rcu_read_lock();
429         err = vport->ops->get_stats(vport, stats);
430         rcu_read_unlock();
431
432         return err;
433 }
434
435 /**
436  *      vport_get_stats - retrieve device stats
437  *
438  * @vport: vport from which to retrieve the stats
439  * @stats: location to store stats
440  *
441  * Retrieves transmit, receive, and error stats for the given device.
442  *
443  * Must be called with RTNL lock or rcu_read_lock.
444  */
445 int vport_get_stats(struct vport *vport, struct rtnl_link_stats64 *stats)
446 {
447         int i;
448
449         if (!(vport->ops->flags & VPORT_F_GEN_STATS))
450                 return vport_call_get_stats(vport, stats);
451
452         /* We potentially have 3 sources of stats that need to be
453          * combined: those we have collected (split into err_stats and
454          * percpu_stats), offset_stats from set_stats(), and device
455          * error stats from get_stats() (for errors that happen
456          * downstream and therefore aren't reported through our
457          * vport_record_error() function). */
458
459         spin_lock_bh(&vport->stats_lock);
460
461         *stats = vport->offset_stats;
462
463         stats->rx_errors        += vport->err_stats.rx_errors;
464         stats->tx_errors        += vport->err_stats.tx_errors;
465         stats->tx_dropped       += vport->err_stats.tx_dropped;
466         stats->rx_dropped       += vport->err_stats.rx_dropped;
467
468         spin_unlock_bh(&vport->stats_lock);
469
470         if (vport->ops->get_stats) {
471                 struct rtnl_link_stats64 dev_stats;
472                 int err;
473
474                 err = vport_call_get_stats(vport, &dev_stats);
475                 if (err)
476                         return err;
477
478                 stats->rx_errors           += dev_stats.rx_errors;
479                 stats->tx_errors           += dev_stats.tx_errors;
480                 stats->rx_dropped          += dev_stats.rx_dropped;
481                 stats->tx_dropped          += dev_stats.tx_dropped;
482                 stats->multicast           += dev_stats.multicast;
483                 stats->collisions          += dev_stats.collisions;
484                 stats->rx_length_errors    += dev_stats.rx_length_errors;
485                 stats->rx_over_errors      += dev_stats.rx_over_errors;
486                 stats->rx_crc_errors       += dev_stats.rx_crc_errors;
487                 stats->rx_frame_errors     += dev_stats.rx_frame_errors;
488                 stats->rx_fifo_errors      += dev_stats.rx_fifo_errors;
489                 stats->rx_missed_errors    += dev_stats.rx_missed_errors;
490                 stats->tx_aborted_errors   += dev_stats.tx_aborted_errors;
491                 stats->tx_carrier_errors   += dev_stats.tx_carrier_errors;
492                 stats->tx_fifo_errors      += dev_stats.tx_fifo_errors;
493                 stats->tx_heartbeat_errors += dev_stats.tx_heartbeat_errors;
494                 stats->tx_window_errors    += dev_stats.tx_window_errors;
495                 stats->rx_compressed       += dev_stats.rx_compressed;
496                 stats->tx_compressed       += dev_stats.tx_compressed;
497         }
498
499         for_each_possible_cpu(i) {
500                 const struct vport_percpu_stats *percpu_stats;
501                 struct vport_percpu_stats local_stats;
502                 unsigned seqcount;
503
504                 percpu_stats = per_cpu_ptr(vport->percpu_stats, i);
505
506                 do {
507                         seqcount = read_seqcount_begin(&percpu_stats->seqlock);
508                         local_stats = *percpu_stats;
509                 } while (read_seqcount_retry(&percpu_stats->seqlock, seqcount));
510
511                 stats->rx_bytes         += local_stats.rx_bytes;
512                 stats->rx_packets       += local_stats.rx_packets;
513                 stats->tx_bytes         += local_stats.tx_bytes;
514                 stats->tx_packets       += local_stats.tx_packets;
515         }
516
517         return 0;
518 }
519
520 /**
521  *      vport_get_flags - retrieve device flags
522  *
523  * @vport: vport from which to retrieve the flags
524  *
525  * Retrieves the flags of the given device.
526  *
527  * Must be called with RTNL lock or rcu_read_lock.
528  */
529 unsigned vport_get_flags(const struct vport *vport)
530 {
531         return vport->ops->get_dev_flags(vport);
532 }
533
534 /**
535  *      vport_get_flags - check whether device is running
536  *
537  * @vport: vport on which to check status.
538  *
539  * Checks whether the given device is running.
540  *
541  * Must be called with RTNL lock or rcu_read_lock.
542  */
543 int vport_is_running(const struct vport *vport)
544 {
545         return vport->ops->is_running(vport);
546 }
547
548 /**
549  *      vport_get_flags - retrieve device operating state
550  *
551  * @vport: vport from which to check status
552  *
553  * Retrieves the RFC2863 operstate of the given device.
554  *
555  * Must be called with RTNL lock or rcu_read_lock.
556  */
557 unsigned char vport_get_operstate(const struct vport *vport)
558 {
559         return vport->ops->get_operstate(vport);
560 }
561
562 /**
563  *      vport_get_ifindex - retrieve device system interface index
564  *
565  * @vport: vport from which to retrieve index
566  *
567  * Retrieves the system interface index of the given device or 0 if
568  * the device does not have one (in the case of virtual ports).
569  * Returns a negative index on error.
570  *
571  * Must be called with RTNL lock or rcu_read_lock.
572  */
573 int vport_get_ifindex(const struct vport *vport)
574 {
575         if (vport->ops->get_ifindex)
576                 return vport->ops->get_ifindex(vport);
577         else
578                 return 0;
579 }
580
581 /**
582  *      vport_get_iflink - retrieve device system link index
583  *
584  * @vport: vport from which to retrieve index
585  *
586  * Retrieves the system link index of the given device.  The link is the index
587  * of the interface on which the packet will actually be sent.  In most cases
588  * this is the same as the ifindex but may be different for tunnel devices.
589  * Returns a negative index on error.
590  *
591  * Must be called with RTNL lock or rcu_read_lock.
592  */
593 int vport_get_iflink(const struct vport *vport)
594 {
595         if (vport->ops->get_iflink)
596                 return vport->ops->get_iflink(vport);
597
598         /* If we don't have an iflink, use the ifindex.  In most cases they
599          * are the same. */
600         return vport_get_ifindex(vport);
601 }
602
603 /**
604  *      vport_get_mtu - retrieve device MTU
605  *
606  * @vport: vport from which to retrieve MTU
607  *
608  * Retrieves the MTU of the given device.
609  *
610  * Must be called with RTNL lock or rcu_read_lock.
611  */
612 int vport_get_mtu(const struct vport *vport)
613 {
614         return vport->ops->get_mtu(vport);
615 }
616
617 /**
618  *      vport_get_options - retrieve device options
619  *
620  * @vport: vport from which to retrieve the options.
621  * @skb: sk_buff where options should be appended.
622  *
623  * Retrieves the configuration of the given device, appending an
624  * %ODP_VPORT_ATTR_OPTIONS attribute that in turn contains nested
625  * vport-specific attributes to @skb.
626  *
627  * Returns 0 if successful, -EMSGSIZE if @skb has insufficient room, or another
628  * negative error code if a real error occurred.  If an error occurs, @skb is
629  * left unmodified.
630  *
631  * Must be called with RTNL lock or rcu_read_lock.
632  */
633 int vport_get_options(const struct vport *vport, struct sk_buff *skb)
634 {
635         struct nlattr *nla;
636
637         nla = nla_nest_start(skb, ODP_VPORT_ATTR_OPTIONS);
638         if (!nla)
639                 return -EMSGSIZE;
640
641         if (vport->ops->get_options) {
642                 int err = vport->ops->get_options(vport, skb);
643                 if (err) {
644                         nla_nest_cancel(skb, nla);
645                         return err;
646                 }
647         }
648
649         nla_nest_end(skb, nla);
650         return 0;
651 }
652
653 /**
654  *      vport_receive - pass up received packet to the datapath for processing
655  *
656  * @vport: vport that received the packet
657  * @skb: skb that was received
658  *
659  * Must be called with rcu_read_lock.  The packet cannot be shared and
660  * skb->data should point to the Ethernet header.  The caller must have already
661  * called compute_ip_summed() to initialize the checksumming fields.
662  */
663 void vport_receive(struct vport *vport, struct sk_buff *skb)
664 {
665         if (vport->ops->flags & VPORT_F_GEN_STATS) {
666                 struct vport_percpu_stats *stats;
667
668                 local_bh_disable();
669                 stats = per_cpu_ptr(vport->percpu_stats, smp_processor_id());
670
671                 write_seqcount_begin(&stats->seqlock);
672                 stats->rx_packets++;
673                 stats->rx_bytes += skb->len;
674                 write_seqcount_end(&stats->seqlock);
675
676                 local_bh_enable();
677         }
678
679         if (!(vport->ops->flags & VPORT_F_FLOW))
680                 OVS_CB(skb)->flow = NULL;
681
682         if (!(vport->ops->flags & VPORT_F_TUN_ID))
683                 OVS_CB(skb)->tun_id = 0;
684
685         dp_process_received_packet(vport, skb);
686 }
687
688 static inline unsigned packet_length(const struct sk_buff *skb)
689 {
690         unsigned length = skb->len - ETH_HLEN;
691
692         if (skb->protocol == htons(ETH_P_8021Q))
693                 length -= VLAN_HLEN;
694
695         return length;
696 }
697
698 /**
699  *      vport_send - send a packet on a device
700  *
701  * @vport: vport on which to send the packet
702  * @skb: skb to send
703  *
704  * Sends the given packet and returns the length of data sent.  Either RTNL
705  * lock or rcu_read_lock must be held.
706  */
707 int vport_send(struct vport *vport, struct sk_buff *skb)
708 {
709         int mtu;
710         int sent;
711
712         mtu = vport_get_mtu(vport);
713         if (unlikely(packet_length(skb) > mtu && !skb_is_gso(skb))) {
714                 if (net_ratelimit())
715                         pr_warn("%s: dropped over-mtu packet: %d > %d\n",
716                                 dp_name(vport->dp), packet_length(skb), mtu);
717                 goto error;
718         }
719
720         sent = vport->ops->send(vport, skb);
721
722         if (vport->ops->flags & VPORT_F_GEN_STATS && sent > 0) {
723                 struct vport_percpu_stats *stats;
724
725                 local_bh_disable();
726                 stats = per_cpu_ptr(vport->percpu_stats, smp_processor_id());
727
728                 write_seqcount_begin(&stats->seqlock);
729                 stats->tx_packets++;
730                 stats->tx_bytes += sent;
731                 write_seqcount_end(&stats->seqlock);
732
733                 local_bh_enable();
734         }
735
736         return sent;
737
738 error:
739         kfree_skb(skb);
740         vport_record_error(vport, VPORT_E_TX_DROPPED);
741         return 0;
742 }
743
744 /**
745  *      vport_record_error - indicate device error to generic stats layer
746  *
747  * @vport: vport that encountered the error
748  * @err_type: one of enum vport_err_type types to indicate the error type
749  *
750  * If using the vport generic stats layer indicate that an error of the given
751  * type has occured.
752  */
753 void vport_record_error(struct vport *vport, enum vport_err_type err_type)
754 {
755         if (vport->ops->flags & VPORT_F_GEN_STATS) {
756
757                 spin_lock_bh(&vport->stats_lock);
758
759                 switch (err_type) {
760                 case VPORT_E_RX_DROPPED:
761                         vport->err_stats.rx_dropped++;
762                         break;
763
764                 case VPORT_E_RX_ERROR:
765                         vport->err_stats.rx_errors++;
766                         break;
767
768                 case VPORT_E_TX_DROPPED:
769                         vport->err_stats.tx_dropped++;
770                         break;
771
772                 case VPORT_E_TX_ERROR:
773                         vport->err_stats.tx_errors++;
774                         break;
775                 };
776
777                 spin_unlock_bh(&vport->stats_lock);
778         }
779 }