LCOV - code coverage report
Current view: top level - include/linux - if_macvlan.h (source / functions) Hit Total Coverage
Test: gcov_data_raspi2_real_modules_combined.info Lines: 0 1 0.0 %
Date: 2020-09-30 20:25:40 Functions: 0 0 -
Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: GPL-2.0 */
       2                 :            : #ifndef _LINUX_IF_MACVLAN_H
       3                 :            : #define _LINUX_IF_MACVLAN_H
       4                 :            : 
       5                 :            : #include <linux/if_link.h>
       6                 :            : #include <linux/if_vlan.h>
       7                 :            : #include <linux/list.h>
       8                 :            : #include <linux/netdevice.h>
       9                 :            : #include <linux/netlink.h>
      10                 :            : #include <net/netlink.h>
      11                 :            : #include <linux/u64_stats_sync.h>
      12                 :            : 
      13                 :            : struct macvlan_port;
      14                 :            : 
      15                 :            : #define MACVLAN_MC_FILTER_BITS  8
      16                 :            : #define MACVLAN_MC_FILTER_SZ    (1 << MACVLAN_MC_FILTER_BITS)
      17                 :            : 
      18                 :            : struct macvlan_dev {
      19                 :            :         struct net_device       *dev;
      20                 :            :         struct list_head        list;
      21                 :            :         struct hlist_node       hlist;
      22                 :            :         struct macvlan_port     *port;
      23                 :            :         struct net_device       *lowerdev;
      24                 :            :         void                    *accel_priv;
      25                 :            :         struct vlan_pcpu_stats __percpu *pcpu_stats;
      26                 :            : 
      27                 :            :         DECLARE_BITMAP(mc_filter, MACVLAN_MC_FILTER_SZ);
      28                 :            : 
      29                 :            :         netdev_features_t       set_features;
      30                 :            :         enum macvlan_mode       mode;
      31                 :            :         u16                     flags;
      32                 :            :         unsigned int            macaddr_count;
      33                 :            : #ifdef CONFIG_NET_POLL_CONTROLLER
      34                 :            :         struct netpoll          *netpoll;
      35                 :            : #endif
      36                 :            : };
      37                 :            : 
      38                 :            : static inline void macvlan_count_rx(const struct macvlan_dev *vlan,
      39                 :            :                                     unsigned int len, bool success,
      40                 :            :                                     bool multicast)
      41                 :            : {
      42                 :            :         if (likely(success)) {
      43                 :            :                 struct vlan_pcpu_stats *pcpu_stats;
      44                 :            : 
      45                 :            :                 pcpu_stats = this_cpu_ptr(vlan->pcpu_stats);
      46                 :            :                 u64_stats_update_begin(&pcpu_stats->syncp);
      47                 :            :                 pcpu_stats->rx_packets++;
      48                 :            :                 pcpu_stats->rx_bytes += len;
      49                 :            :                 if (multicast)
      50                 :            :                         pcpu_stats->rx_multicast++;
      51                 :            :                 u64_stats_update_end(&pcpu_stats->syncp);
      52                 :            :         } else {
      53                 :            :                 this_cpu_inc(vlan->pcpu_stats->rx_errors);
      54                 :            :         }
      55                 :            : }
      56                 :            : 
      57                 :            : extern void macvlan_common_setup(struct net_device *dev);
      58                 :            : 
      59                 :            : extern int macvlan_common_newlink(struct net *src_net, struct net_device *dev,
      60                 :            :                                   struct nlattr *tb[], struct nlattr *data[],
      61                 :            :                                   struct netlink_ext_ack *extack);
      62                 :            : 
      63                 :            : extern void macvlan_dellink(struct net_device *dev, struct list_head *head);
      64                 :            : 
      65                 :            : extern int macvlan_link_register(struct rtnl_link_ops *ops);
      66                 :            : 
      67                 :            : #if IS_ENABLED(CONFIG_MACVLAN)
      68                 :            : static inline struct net_device *
      69                 :            : macvlan_dev_real_dev(const struct net_device *dev)
      70                 :            : {
      71                 :            :         struct macvlan_dev *macvlan = netdev_priv(dev);
      72                 :            : 
      73                 :          0 :         return macvlan->lowerdev;
      74                 :            : }
      75                 :            : #else
      76                 :            : static inline struct net_device *
      77                 :            : macvlan_dev_real_dev(const struct net_device *dev)
      78                 :            : {
      79                 :            :         BUG();
      80                 :            :         return NULL;
      81                 :            : }
      82                 :            : #endif
      83                 :            : 
      84                 :            : static inline void *macvlan_accel_priv(struct net_device *dev)
      85                 :            : {
      86                 :            :         struct macvlan_dev *macvlan = netdev_priv(dev);
      87                 :            : 
      88                 :            :         return macvlan->accel_priv;
      89                 :            : }
      90                 :            : 
      91                 :            : static inline bool macvlan_supports_dest_filter(struct net_device *dev)
      92                 :            : {
      93                 :            :         struct macvlan_dev *macvlan = netdev_priv(dev);
      94                 :            : 
      95                 :            :         return macvlan->mode == MACVLAN_MODE_PRIVATE ||
      96                 :            :                macvlan->mode == MACVLAN_MODE_VEPA ||
      97                 :            :                macvlan->mode == MACVLAN_MODE_BRIDGE;
      98                 :            : }
      99                 :            : 
     100                 :            : static inline int macvlan_release_l2fw_offload(struct net_device *dev)
     101                 :            : {
     102                 :            :         struct macvlan_dev *macvlan = netdev_priv(dev);
     103                 :            : 
     104                 :            :         macvlan->accel_priv = NULL;
     105                 :            :         return dev_uc_add(macvlan->lowerdev, dev->dev_addr);
     106                 :            : }
     107                 :            : #endif /* _LINUX_IF_MACVLAN_H */

Generated by: LCOV version 1.14