diff options
Diffstat (limited to 'include/linux/netdevice.h')
| -rw-r--r-- | include/linux/netdevice.h | 163 | 
1 files changed, 118 insertions, 45 deletions
| diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index f45929ce8157..076df5360ba5 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -61,6 +61,9 @@ struct wireless_dev;  /* 802.15.4 specific */  struct wpan_dev;  struct mpls_dev; +/* UDP Tunnel offloads */ +struct udp_tunnel_info; +struct bpf_prog;  void netdev_set_default_ethtool_ops(struct net_device *dev,  				    const struct ethtool_ops *ops); @@ -90,7 +93,6 @@ void netdev_set_default_ethtool_ops(struct net_device *dev,  #define NET_XMIT_SUCCESS	0x00  #define NET_XMIT_DROP		0x01	/* skb dropped			*/  #define NET_XMIT_CN		0x02	/* congestion notification	*/ -#define NET_XMIT_POLICED	0x03	/* skb is shot by police	*/  #define NET_XMIT_MASK		0x0f	/* qdisc flags in net/sch_generic.h */  /* NET_XMIT_CN is special. It does not guarantee that this packet is lost. It @@ -785,6 +787,7 @@ enum {  	TC_SETUP_MQPRIO,  	TC_SETUP_CLSU32,  	TC_SETUP_CLSFLOWER, +	TC_SETUP_MATCHALL,  };  struct tc_cls_u32_offload; @@ -795,9 +798,37 @@ struct tc_to_netdev {  		u8 tc;  		struct tc_cls_u32_offload *cls_u32;  		struct tc_cls_flower_offload *cls_flower; +		struct tc_cls_matchall_offload *cls_mall;  	};  }; +/* These structures hold the attributes of xdp state that are being passed + * to the netdevice through the xdp op. + */ +enum xdp_netdev_command { +	/* Set or clear a bpf program used in the earliest stages of packet +	 * rx. The prog will have been loaded as BPF_PROG_TYPE_XDP. The callee +	 * is responsible for calling bpf_prog_put on any old progs that are +	 * stored. In case of error, the callee need not release the new prog +	 * reference, but on success it takes ownership and must bpf_prog_put +	 * when it is no longer used. +	 */ +	XDP_SETUP_PROG, +	/* Check if a bpf program is set on the device.  The callee should +	 * return true if a program is currently attached and running. +	 */ +	XDP_QUERY_PROG, +}; + +struct netdev_xdp { +	enum xdp_netdev_command command; +	union { +		/* XDP_SETUP_PROG */ +		struct bpf_prog *prog; +		/* XDP_QUERY_PROG */ +		bool prog_attached; +	}; +};  /*   * This structure defines the management hooks for network devices. @@ -1025,31 +1056,18 @@ struct tc_to_netdev {   *	not implement this, it is assumed that the hw is not able to have   *	multiple net devices on single physical port.   * - * void (*ndo_add_vxlan_port)(struct  net_device *dev, - *			      sa_family_t sa_family, __be16 port); - *	Called by vxlan to notify a driver about the UDP port and socket - *	address family that vxlan is listening to. It is called only when - *	a new port starts listening. The operation is protected by the - *	vxlan_net->sock_lock. - * - * void (*ndo_add_geneve_port)(struct net_device *dev, - *			       sa_family_t sa_family, __be16 port); - *	Called by geneve to notify a driver about the UDP port and socket - *	address family that geneve is listnening to. It is called only when - *	a new port starts listening. The operation is protected by the - *	geneve_net->sock_lock. - * - * void (*ndo_del_geneve_port)(struct net_device *dev, - *			       sa_family_t sa_family, __be16 port); - *	Called by geneve to notify the driver about a UDP port and socket - *	address family that geneve is not listening to anymore. The operation - *	is protected by the geneve_net->sock_lock. - * - * void (*ndo_del_vxlan_port)(struct  net_device *dev, - *			      sa_family_t sa_family, __be16 port); - *	Called by vxlan to notify the driver about a UDP port and socket - *	address family that vxlan is not listening to anymore. The operation - *	is protected by the vxlan_net->sock_lock. + * void (*ndo_udp_tunnel_add)(struct net_device *dev, + *			      struct udp_tunnel_info *ti); + *	Called by UDP tunnel to notify a driver about the UDP port and socket + *	address family that a UDP tunnel is listnening to. It is called only + *	when a new port starts listening. The operation is protected by the + *	RTNL. + * + * void (*ndo_udp_tunnel_del)(struct net_device *dev, + *			      struct udp_tunnel_info *ti); + *	Called by UDP tunnel to notify the driver about a UDP port and socket + *	address family that the UDP tunnel is not listening to anymore. The + *	operation is protected by the RTNL.   *   * void* (*ndo_dfwd_add_station)(struct net_device *pdev,   *				 struct net_device *dev) @@ -1099,6 +1117,9 @@ struct tc_to_netdev {   *	appropriate rx headroom value allows avoiding skb head copy on   *	forward. Setting a negative value resets the rx headroom to the   *	default value. + * int (*ndo_xdp)(struct net_device *dev, struct netdev_xdp *xdp); + *	This function is used to set or query state related to XDP on the + *	netdevice. See definition of enum xdp_netdev_command for details.   *   */  struct net_device_ops { @@ -1221,8 +1242,10 @@ struct net_device_ops {  						    netdev_features_t features);  	int			(*ndo_set_features)(struct net_device *dev,  						    netdev_features_t features); -	int			(*ndo_neigh_construct)(struct neighbour *n); -	void			(*ndo_neigh_destroy)(struct neighbour *n); +	int			(*ndo_neigh_construct)(struct net_device *dev, +						       struct neighbour *n); +	void			(*ndo_neigh_destroy)(struct net_device *dev, +						     struct neighbour *n);  	int			(*ndo_fdb_add)(struct ndmsg *ndm,  					       struct nlattr *tb[], @@ -1258,18 +1281,10 @@ struct net_device_ops {  							struct netdev_phys_item_id *ppid);  	int			(*ndo_get_phys_port_name)(struct net_device *dev,  							  char *name, size_t len); -	void			(*ndo_add_vxlan_port)(struct  net_device *dev, -						      sa_family_t sa_family, -						      __be16 port); -	void			(*ndo_del_vxlan_port)(struct  net_device *dev, -						      sa_family_t sa_family, -						      __be16 port); -	void			(*ndo_add_geneve_port)(struct  net_device *dev, -						       sa_family_t sa_family, -						       __be16 port); -	void			(*ndo_del_geneve_port)(struct  net_device *dev, -						       sa_family_t sa_family, -						       __be16 port); +	void			(*ndo_udp_tunnel_add)(struct net_device *dev, +						      struct udp_tunnel_info *ti); +	void			(*ndo_udp_tunnel_del)(struct net_device *dev, +						      struct udp_tunnel_info *ti);  	void*			(*ndo_dfwd_add_station)(struct net_device *pdev,  							struct net_device *dev);  	void			(*ndo_dfwd_del_station)(struct net_device *pdev, @@ -1289,6 +1304,8 @@ struct net_device_ops {  						       struct sk_buff *skb);  	void			(*ndo_set_rx_headroom)(struct net_device *dev,  						       int needed_headroom); +	int			(*ndo_xdp)(struct net_device *dev, +					   struct netdev_xdp *xdp);  };  /** @@ -1457,6 +1474,8 @@ enum netdev_priv_flags {   *	@netdev_ops:	Includes several pointers to callbacks,   *			if one wants to override the ndo_*() functions   *	@ethtool_ops:	Management operations + *	@ndisc_ops:	Includes callbacks for different IPv6 neighbour + *			discovery handling. Necessary for e.g. 6LoWPAN.   *	@header_ops:	Includes callbacks for creating,parsing,caching,etc   *			of Layer 2 headers.   * @@ -1484,8 +1503,7 @@ enum netdev_priv_flags {   * 	@perm_addr:		Permanent hw address   * 	@addr_assign_type:	Hw address assignment type   * 	@addr_len:		Hardware address length - * 	@neigh_priv_len;	Used in neigh_alloc(), - * 				initialized only in atm/clip.c + *	@neigh_priv_len:	Used in neigh_alloc()   * 	@dev_id:		Used to differentiate devices that share   * 				the same link layer address   * 	@dev_port:		Used to differentiate devices that share @@ -1594,7 +1612,8 @@ enum netdev_priv_flags {   *	@phydev:	Physical device may attach itself   *			for hardware timestamping   * - *	@qdisc_tx_busylock:	XXX: need comments on this one + *	@qdisc_tx_busylock: lockdep class annotating Qdisc->busylock spinlock + *	@qdisc_running_key: lockdep class annotating Qdisc->running seqcount   *   *	@proto_down:	protocol port state information can be sent to the   *			switch driver and used to set the phys state of the @@ -1673,6 +1692,9 @@ struct net_device {  #ifdef CONFIG_NET_L3_MASTER_DEV  	const struct l3mdev_ops	*l3mdev_ops;  #endif +#if IS_ENABLED(CONFIG_IPV6) +	const struct ndisc_ops *ndisc_ops; +#endif  	const struct header_ops *header_ops; @@ -1862,6 +1884,7 @@ struct net_device {  #endif  	struct phy_device	*phydev;  	struct lock_class_key	*qdisc_tx_busylock; +	struct lock_class_key	*qdisc_running_key;  	bool			proto_down;  };  #define to_net_dev(d) container_of(d, struct net_device, dev) @@ -1944,6 +1967,23 @@ static inline void netdev_for_each_tx_queue(struct net_device *dev,  		f(dev, &dev->_tx[i], arg);  } +#define netdev_lockdep_set_classes(dev)				\ +{								\ +	static struct lock_class_key qdisc_tx_busylock_key;	\ +	static struct lock_class_key qdisc_running_key;		\ +	static struct lock_class_key qdisc_xmit_lock_key;	\ +	static struct lock_class_key dev_addr_list_lock_key;	\ +	unsigned int i;						\ +								\ +	(dev)->qdisc_tx_busylock = &qdisc_tx_busylock_key;	\ +	(dev)->qdisc_running_key = &qdisc_running_key;		\ +	lockdep_set_class(&(dev)->addr_list_lock,		\ +			  &dev_addr_list_lock_key); 		\ +	for (i = 0; i < (dev)->num_tx_queues; i++)		\ +		lockdep_set_class(&(dev)->_tx[i]._xmit_lock,	\ +				  &qdisc_xmit_lock_key);	\ +} +  struct netdev_queue *netdev_pick_tx(struct net_device *dev,  				    struct sk_buff *skb,  				    void *accel_priv); @@ -2233,8 +2273,8 @@ struct netdev_lag_lower_state_info {  #define NETDEV_BONDING_INFO	0x0019  #define NETDEV_PRECHANGEUPPER	0x001A  #define NETDEV_CHANGELOWERSTATE	0x001B -#define NETDEV_OFFLOAD_PUSH_VXLAN	0x001C -#define NETDEV_OFFLOAD_PUSH_GENEVE	0x001D +#define NETDEV_UDP_TUNNEL_PUSH_INFO	0x001C +#define NETDEV_CHANGE_TX_QUEUE_LEN	0x001E  int register_netdevice_notifier(struct notifier_block *nb);  int unregister_netdevice_notifier(struct notifier_block *nb); @@ -2370,6 +2410,8 @@ void synchronize_net(void);  int init_dummy_netdev(struct net_device *dev);  DECLARE_PER_CPU(int, xmit_recursion); +#define XMIT_RECURSION_LIMIT	10 +  static inline int dev_recursion_level(void)  {  	return this_cpu_read(xmit_recursion); @@ -3250,6 +3292,7 @@ int dev_get_phys_port_id(struct net_device *dev,  int dev_get_phys_port_name(struct net_device *dev,  			   char *name, size_t len);  int dev_change_proto_down(struct net_device *dev, bool proto_down); +int dev_change_xdp_fd(struct net_device *dev, int fd);  struct sk_buff *validate_xmit_skb_list(struct sk_buff *skb, struct net_device *dev);  struct sk_buff *dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev,  				    struct netdev_queue *txq, int *ret); @@ -3799,12 +3842,30 @@ void *netdev_lower_get_next_private_rcu(struct net_device *dev,  void *netdev_lower_get_next(struct net_device *dev,  				struct list_head **iter); +  #define netdev_for_each_lower_dev(dev, ldev, iter) \  	for (iter = (dev)->adj_list.lower.next, \  	     ldev = netdev_lower_get_next(dev, &(iter)); \  	     ldev; \  	     ldev = netdev_lower_get_next(dev, &(iter))) +struct net_device *netdev_all_lower_get_next(struct net_device *dev, +					     struct list_head **iter); +struct net_device *netdev_all_lower_get_next_rcu(struct net_device *dev, +						 struct list_head **iter); + +#define netdev_for_each_all_lower_dev(dev, ldev, iter) \ +	for (iter = (dev)->all_adj_list.lower.next, \ +	     ldev = netdev_all_lower_get_next(dev, &(iter)); \ +	     ldev; \ +	     ldev = netdev_all_lower_get_next(dev, &(iter))) + +#define netdev_for_each_all_lower_dev_rcu(dev, ldev, iter) \ +	for (iter = (dev)->all_adj_list.lower.next, \ +	     ldev = netdev_all_lower_get_next_rcu(dev, &(iter)); \ +	     ldev; \ +	     ldev = netdev_all_lower_get_next_rcu(dev, &(iter))) +  void *netdev_adjacent_get_private(struct list_head *adj_list);  void *netdev_lower_get_first_private_rcu(struct net_device *dev);  struct net_device *netdev_master_upper_dev_get(struct net_device *dev); @@ -3820,6 +3881,10 @@ void *netdev_lower_dev_get_private(struct net_device *dev,  				   struct net_device *lower_dev);  void netdev_lower_state_changed(struct net_device *lower_dev,  				void *lower_state_info); +int netdev_default_l2upper_neigh_construct(struct net_device *dev, +					   struct neighbour *n); +void netdev_default_l2upper_neigh_destroy(struct net_device *dev, +					  struct neighbour *n);  /* RSS keys are 40 or 52 bytes long */  #define NETDEV_RSS_KEY_LEN 52 @@ -4012,6 +4077,7 @@ static inline bool net_gso_ok(netdev_features_t features, int gso_type)  	BUILD_BUG_ON(SKB_GSO_UDP_TUNNEL_CSUM != (NETIF_F_GSO_UDP_TUNNEL_CSUM >> NETIF_F_GSO_SHIFT));  	BUILD_BUG_ON(SKB_GSO_PARTIAL != (NETIF_F_GSO_PARTIAL >> NETIF_F_GSO_SHIFT));  	BUILD_BUG_ON(SKB_GSO_TUNNEL_REMCSUM != (NETIF_F_GSO_TUNNEL_REMCSUM >> NETIF_F_GSO_SHIFT)); +	BUILD_BUG_ON(SKB_GSO_SCTP    != (NETIF_F_GSO_SCTP >> NETIF_F_GSO_SHIFT));  	return (features & feature) == feature;  } @@ -4145,6 +4211,13 @@ static inline void netif_keep_dst(struct net_device *dev)  	dev->priv_flags &= ~(IFF_XMIT_DST_RELEASE | IFF_XMIT_DST_RELEASE_PERM);  } +/* return true if dev can't cope with mtu frames that need vlan tag insertion */ +static inline bool netif_reduces_vlan_mtu(struct net_device *dev) +{ +	/* TODO: reserve and use an additional IFF bit, if we get more users */ +	return dev->priv_flags & IFF_MACSEC; +} +  extern struct pernet_operations __net_initdata loopback_net_ops;  /* Logging, debugging and troubleshooting/diagnostic helpers. */ |