Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0-or-later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /* -*- linux-c -*-
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * INET		802.1Q VLAN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *		Ethernet-type device handling.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  * Authors:	Ben Greear <greearb@candelatech.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  *              Please send support related email to: netdev@vger.kernel.org
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  *              VLAN Home Page: http://www.candelatech.com/~greear/vlan.html
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10)  * Fixes:       Mar 22 2001: Martin Bokaemper <mbokaemper@unispherenetworks.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11)  *                - reset skb->pkt_type on incoming packets when MAC was changed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12)  *                - see that changed MAC is saddr for outgoing packets
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13)  *              Oct 20, 2001:  Ard van Breeman:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14)  *                - Fix MC-list, finally.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15)  *                - Flush MC-list on VLAN destroy.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) #include <linux/skbuff.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) #include <linux/netdevice.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) #include <linux/net_tstamp.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) #include <linux/etherdevice.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) #include <linux/ethtool.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) #include <linux/phy.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) #include <net/arp.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) #include "vlan.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) #include "vlanproc.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) #include <linux/if_vlan.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) #include <linux/netpoll.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36)  *	Create the VLAN header for an arbitrary protocol layer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38)  *	saddr=NULL	means use device source address
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39)  *	daddr=NULL	means leave destination address (eg unresolved arp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41)  *  This is called when the SKB is moving down the stack towards the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42)  *  physical devices.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) static int vlan_dev_hard_header(struct sk_buff *skb, struct net_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 				unsigned short type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 				const void *daddr, const void *saddr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 				unsigned int len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 	struct vlan_dev_priv *vlan = vlan_dev_priv(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 	struct vlan_hdr *vhdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	unsigned int vhdrlen = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	u16 vlan_tci = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 	int rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 	if (!(vlan->flags & VLAN_FLAG_REORDER_HDR)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 		vhdr = skb_push(skb, VLAN_HLEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 		vlan_tci = vlan->vlan_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 		vlan_tci |= vlan_dev_get_egress_qos_mask(dev, skb->priority);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 		vhdr->h_vlan_TCI = htons(vlan_tci);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 		 *  Set the protocol type. For a packet of type ETH_P_802_3/2 we
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 		 *  put the length in here instead.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 		if (type != ETH_P_802_3 && type != ETH_P_802_2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 			vhdr->h_vlan_encapsulated_proto = htons(type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 			vhdr->h_vlan_encapsulated_proto = htons(len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 		skb->protocol = vlan->vlan_proto;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 		type = ntohs(vlan->vlan_proto);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 		vhdrlen = VLAN_HLEN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	/* Before delegating work to the lower layer, enter our MAC-address */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 	if (saddr == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 		saddr = dev->dev_addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	/* Now make the underlying real hard header */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	dev = vlan->real_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 	rc = dev_hard_header(skb, dev, type, daddr, saddr, len + vhdrlen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	if (rc > 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 		rc += vhdrlen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) static inline netdev_tx_t vlan_netpoll_send_skb(struct vlan_dev_priv *vlan, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) #ifdef CONFIG_NET_POLL_CONTROLLER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	return netpoll_send_skb(vlan->netpoll, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 	BUG();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	return NETDEV_TX_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) static netdev_tx_t vlan_dev_hard_start_xmit(struct sk_buff *skb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 					    struct net_device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 	struct vlan_dev_priv *vlan = vlan_dev_priv(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 	struct vlan_ethhdr *veth = (struct vlan_ethhdr *)(skb->data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 	unsigned int len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 	/* Handle non-VLAN frames if they are sent to us, for example by DHCP.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 	 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 	 * NOTE: THIS ASSUMES DIX ETHERNET, SPECIFICALLY NOT SUPPORTING
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	 * OTHER THINGS LIKE FDDI/TokenRing/802.3 SNAPs...
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 	if (veth->h_vlan_proto != vlan->vlan_proto ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 	    vlan->flags & VLAN_FLAG_REORDER_HDR) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 		u16 vlan_tci;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 		vlan_tci = vlan->vlan_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 		vlan_tci |= vlan_dev_get_egress_qos_mask(dev, skb->priority);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 		__vlan_hwaccel_put_tag(skb, vlan->vlan_proto, vlan_tci);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 	skb->dev = vlan->real_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 	len = skb->len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 	if (unlikely(netpoll_tx_running(dev)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 		return vlan_netpoll_send_skb(vlan, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 	ret = dev_queue_xmit(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 	if (likely(ret == NET_XMIT_SUCCESS || ret == NET_XMIT_CN)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 		struct vlan_pcpu_stats *stats;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 		stats = this_cpu_ptr(vlan->vlan_pcpu_stats);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 		u64_stats_update_begin(&stats->syncp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 		stats->tx_packets++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 		stats->tx_bytes += len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 		u64_stats_update_end(&stats->syncp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 		this_cpu_inc(vlan->vlan_pcpu_stats->tx_dropped);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) static int vlan_dev_change_mtu(struct net_device *dev, int new_mtu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 	struct net_device *real_dev = vlan_dev_priv(dev)->real_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 	unsigned int max_mtu = real_dev->mtu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 	if (netif_reduces_vlan_mtu(real_dev))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 		max_mtu -= VLAN_HLEN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 	if (max_mtu < new_mtu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 		return -ERANGE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 	dev->mtu = new_mtu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) void vlan_dev_set_ingress_priority(const struct net_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 				   u32 skb_prio, u16 vlan_prio)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 	struct vlan_dev_priv *vlan = vlan_dev_priv(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 	if (vlan->ingress_priority_map[vlan_prio & 0x7] && !skb_prio)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 		vlan->nr_ingress_mappings--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 	else if (!vlan->ingress_priority_map[vlan_prio & 0x7] && skb_prio)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 		vlan->nr_ingress_mappings++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 	vlan->ingress_priority_map[vlan_prio & 0x7] = skb_prio;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) int vlan_dev_set_egress_priority(const struct net_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 				 u32 skb_prio, u16 vlan_prio)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 	struct vlan_dev_priv *vlan = vlan_dev_priv(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 	struct vlan_priority_tci_mapping *mp = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 	struct vlan_priority_tci_mapping *np;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 	u32 vlan_qos = (vlan_prio << VLAN_PRIO_SHIFT) & VLAN_PRIO_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 	/* See if a priority mapping exists.. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 	mp = vlan->egress_priority_map[skb_prio & 0xF];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 	while (mp) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 		if (mp->priority == skb_prio) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 			if (mp->vlan_qos && !vlan_qos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 				vlan->nr_egress_mappings--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 			else if (!mp->vlan_qos && vlan_qos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 				vlan->nr_egress_mappings++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 			mp->vlan_qos = vlan_qos;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 			return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 		mp = mp->next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 	/* Create a new mapping then. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 	mp = vlan->egress_priority_map[skb_prio & 0xF];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 	np = kmalloc(sizeof(struct vlan_priority_tci_mapping), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 	if (!np)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 		return -ENOBUFS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 	np->next = mp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 	np->priority = skb_prio;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 	np->vlan_qos = vlan_qos;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 	/* Before inserting this element in hash table, make sure all its fields
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 	 * are committed to memory.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 	 * coupled with smp_rmb() in vlan_dev_get_egress_qos_mask()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 	smp_wmb();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 	vlan->egress_priority_map[skb_prio & 0xF] = np;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 	if (vlan_qos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 		vlan->nr_egress_mappings++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) /* Flags are defined in the vlan_flags enum in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212)  * include/uapi/linux/if_vlan.h file.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) int vlan_dev_change_flags(const struct net_device *dev, u32 flags, u32 mask)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 	struct vlan_dev_priv *vlan = vlan_dev_priv(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 	u32 old_flags = vlan->flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 	if (mask & ~(VLAN_FLAG_REORDER_HDR | VLAN_FLAG_GVRP |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 		     VLAN_FLAG_LOOSE_BINDING | VLAN_FLAG_MVRP |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 		     VLAN_FLAG_BRIDGE_BINDING))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 	vlan->flags = (old_flags & ~mask) | (flags & mask);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 	if (netif_running(dev) && (vlan->flags ^ old_flags) & VLAN_FLAG_GVRP) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 		if (vlan->flags & VLAN_FLAG_GVRP)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 			vlan_gvrp_request_join(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 			vlan_gvrp_request_leave(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 	if (netif_running(dev) && (vlan->flags ^ old_flags) & VLAN_FLAG_MVRP) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 		if (vlan->flags & VLAN_FLAG_MVRP)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 			vlan_mvrp_request_join(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 			vlan_mvrp_request_leave(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) void vlan_dev_get_realdev_name(const struct net_device *dev, char *result)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 	strncpy(result, vlan_dev_priv(dev)->real_dev->name, 23);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) bool vlan_dev_inherit_address(struct net_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 			      struct net_device *real_dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 	if (dev->addr_assign_type != NET_ADDR_STOLEN)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 		return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 	ether_addr_copy(dev->dev_addr, real_dev->dev_addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 	call_netdevice_notifiers(NETDEV_CHANGEADDR, dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 	return true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) static int vlan_dev_open(struct net_device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 	struct vlan_dev_priv *vlan = vlan_dev_priv(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 	struct net_device *real_dev = vlan->real_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 	int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 	if (!(real_dev->flags & IFF_UP) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 	    !(vlan->flags & VLAN_FLAG_LOOSE_BINDING))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) 		return -ENETDOWN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) 	if (!ether_addr_equal(dev->dev_addr, real_dev->dev_addr) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 	    !vlan_dev_inherit_address(dev, real_dev)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 		err = dev_uc_add(real_dev, dev->dev_addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 		if (err < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 			goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 	if (dev->flags & IFF_ALLMULTI) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 		err = dev_set_allmulti(real_dev, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 		if (err < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 			goto del_unicast;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 	if (dev->flags & IFF_PROMISC) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) 		err = dev_set_promiscuity(real_dev, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 		if (err < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 			goto clear_allmulti;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 	ether_addr_copy(vlan->real_dev_addr, real_dev->dev_addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) 	if (vlan->flags & VLAN_FLAG_GVRP)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 		vlan_gvrp_request_join(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 	if (vlan->flags & VLAN_FLAG_MVRP)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 		vlan_mvrp_request_join(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 	if (netif_carrier_ok(real_dev) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) 	    !(vlan->flags & VLAN_FLAG_BRIDGE_BINDING))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) 		netif_carrier_on(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) clear_allmulti:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) 	if (dev->flags & IFF_ALLMULTI)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) 		dev_set_allmulti(real_dev, -1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) del_unicast:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) 	if (!ether_addr_equal(dev->dev_addr, real_dev->dev_addr))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) 		dev_uc_del(real_dev, dev->dev_addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) 	netif_carrier_off(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) 	return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) static int vlan_dev_stop(struct net_device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) 	struct vlan_dev_priv *vlan = vlan_dev_priv(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) 	struct net_device *real_dev = vlan->real_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) 	dev_mc_unsync(real_dev, dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) 	dev_uc_unsync(real_dev, dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) 	if (dev->flags & IFF_ALLMULTI)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) 		dev_set_allmulti(real_dev, -1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) 	if (dev->flags & IFF_PROMISC)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) 		dev_set_promiscuity(real_dev, -1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) 	if (!ether_addr_equal(dev->dev_addr, real_dev->dev_addr))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) 		dev_uc_del(real_dev, dev->dev_addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) 	if (!(vlan->flags & VLAN_FLAG_BRIDGE_BINDING))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) 		netif_carrier_off(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) static int vlan_dev_set_mac_address(struct net_device *dev, void *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) 	struct net_device *real_dev = vlan_dev_priv(dev)->real_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) 	struct sockaddr *addr = p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) 	int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) 	if (!is_valid_ether_addr(addr->sa_data))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) 		return -EADDRNOTAVAIL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) 	if (!(dev->flags & IFF_UP))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) 	if (!ether_addr_equal(addr->sa_data, real_dev->dev_addr)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) 		err = dev_uc_add(real_dev, addr->sa_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) 		if (err < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) 			return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) 	if (!ether_addr_equal(dev->dev_addr, real_dev->dev_addr))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) 		dev_uc_del(real_dev, dev->dev_addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) 	ether_addr_copy(dev->dev_addr, addr->sa_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) static int vlan_dev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) 	struct net_device *real_dev = vlan_dev_priv(dev)->real_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) 	const struct net_device_ops *ops = real_dev->netdev_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) 	struct ifreq ifrr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) 	int err = -EOPNOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) 	strncpy(ifrr.ifr_name, real_dev->name, IFNAMSIZ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) 	ifrr.ifr_ifru = ifr->ifr_ifru;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) 	switch (cmd) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) 	case SIOCSHWTSTAMP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) 		if (!net_eq(dev_net(dev), &init_net))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) 		fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) 	case SIOCGMIIPHY:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) 	case SIOCGMIIREG:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) 	case SIOCSMIIREG:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) 	case SIOCGHWTSTAMP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) 		if (netif_device_present(real_dev) && ops->ndo_do_ioctl)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) 			err = ops->ndo_do_ioctl(real_dev, &ifrr, cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) 	if (!err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) 		ifr->ifr_ifru = ifrr.ifr_ifru;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) 	return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) static int vlan_dev_neigh_setup(struct net_device *dev, struct neigh_parms *pa)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) 	struct net_device *real_dev = vlan_dev_priv(dev)->real_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) 	const struct net_device_ops *ops = real_dev->netdev_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) 	int err = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) 	if (netif_device_present(real_dev) && ops->ndo_neigh_setup)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) 		err = ops->ndo_neigh_setup(real_dev, pa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) 	return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) #if IS_ENABLED(CONFIG_FCOE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) static int vlan_dev_fcoe_ddp_setup(struct net_device *dev, u16 xid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) 				   struct scatterlist *sgl, unsigned int sgc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) 	struct net_device *real_dev = vlan_dev_priv(dev)->real_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) 	const struct net_device_ops *ops = real_dev->netdev_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) 	int rc = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) 	if (ops->ndo_fcoe_ddp_setup)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) 		rc = ops->ndo_fcoe_ddp_setup(real_dev, xid, sgl, sgc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) 	return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) static int vlan_dev_fcoe_ddp_done(struct net_device *dev, u16 xid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) 	struct net_device *real_dev = vlan_dev_priv(dev)->real_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) 	const struct net_device_ops *ops = real_dev->netdev_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) 	int len = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) 	if (ops->ndo_fcoe_ddp_done)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) 		len = ops->ndo_fcoe_ddp_done(real_dev, xid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) 	return len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) static int vlan_dev_fcoe_enable(struct net_device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) 	struct net_device *real_dev = vlan_dev_priv(dev)->real_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) 	const struct net_device_ops *ops = real_dev->netdev_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) 	int rc = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) 	if (ops->ndo_fcoe_enable)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) 		rc = ops->ndo_fcoe_enable(real_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) 	return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) static int vlan_dev_fcoe_disable(struct net_device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) 	struct net_device *real_dev = vlan_dev_priv(dev)->real_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) 	const struct net_device_ops *ops = real_dev->netdev_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) 	int rc = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) 	if (ops->ndo_fcoe_disable)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) 		rc = ops->ndo_fcoe_disable(real_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) 	return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) static int vlan_dev_fcoe_ddp_target(struct net_device *dev, u16 xid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) 				    struct scatterlist *sgl, unsigned int sgc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) 	struct net_device *real_dev = vlan_dev_priv(dev)->real_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) 	const struct net_device_ops *ops = real_dev->netdev_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) 	int rc = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) 	if (ops->ndo_fcoe_ddp_target)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) 		rc = ops->ndo_fcoe_ddp_target(real_dev, xid, sgl, sgc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) 	return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) #ifdef NETDEV_FCOE_WWNN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) static int vlan_dev_fcoe_get_wwn(struct net_device *dev, u64 *wwn, int type)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) 	struct net_device *real_dev = vlan_dev_priv(dev)->real_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) 	const struct net_device_ops *ops = real_dev->netdev_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) 	int rc = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) 	if (ops->ndo_fcoe_get_wwn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) 		rc = ops->ndo_fcoe_get_wwn(real_dev, wwn, type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) 	return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) static void vlan_dev_change_rx_flags(struct net_device *dev, int change)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) 	struct net_device *real_dev = vlan_dev_priv(dev)->real_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) 	if (dev->flags & IFF_UP) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) 		if (change & IFF_ALLMULTI)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) 			dev_set_allmulti(real_dev, dev->flags & IFF_ALLMULTI ? 1 : -1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) 		if (change & IFF_PROMISC)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) 			dev_set_promiscuity(real_dev, dev->flags & IFF_PROMISC ? 1 : -1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) static void vlan_dev_set_rx_mode(struct net_device *vlan_dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) 	dev_mc_sync(vlan_dev_priv(vlan_dev)->real_dev, vlan_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) 	dev_uc_sync(vlan_dev_priv(vlan_dev)->real_dev, vlan_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492)  * vlan network devices have devices nesting below it, and are a special
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493)  * "super class" of normal network devices; split their locks off into a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494)  * separate class since they always nest.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) static struct lock_class_key vlan_netdev_xmit_lock_key;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) static struct lock_class_key vlan_netdev_addr_lock_key;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) static void vlan_dev_set_lockdep_one(struct net_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) 				     struct netdev_queue *txq,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) 				     void *unused)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) 	lockdep_set_class(&txq->_xmit_lock, &vlan_netdev_xmit_lock_key);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) static void vlan_dev_set_lockdep_class(struct net_device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) 	lockdep_set_class(&dev->addr_list_lock,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) 			  &vlan_netdev_addr_lock_key);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) 	netdev_for_each_tx_queue(dev, vlan_dev_set_lockdep_one, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) static const struct header_ops vlan_header_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) 	.create	 = vlan_dev_hard_header,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) 	.parse	 = eth_header_parse,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) static int vlan_passthru_hard_header(struct sk_buff *skb, struct net_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) 				     unsigned short type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) 				     const void *daddr, const void *saddr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) 				     unsigned int len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) 	struct vlan_dev_priv *vlan = vlan_dev_priv(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) 	struct net_device *real_dev = vlan->real_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) 	if (saddr == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) 		saddr = dev->dev_addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) 	return dev_hard_header(skb, real_dev, type, daddr, saddr, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) static const struct header_ops vlan_passthru_header_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) 	.create	 = vlan_passthru_hard_header,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) 	.parse	 = eth_header_parse,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) static struct device_type vlan_type = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) 	.name	= "vlan",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) static const struct net_device_ops vlan_netdev_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) static int vlan_dev_init(struct net_device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) 	struct vlan_dev_priv *vlan = vlan_dev_priv(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) 	struct net_device *real_dev = vlan->real_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) 	netif_carrier_off(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) 	/* IFF_BROADCAST|IFF_MULTICAST; ??? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) 	dev->flags  = real_dev->flags & ~(IFF_UP | IFF_PROMISC | IFF_ALLMULTI |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) 					  IFF_MASTER | IFF_SLAVE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) 	dev->state  = (real_dev->state & ((1<<__LINK_STATE_NOCARRIER) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) 					  (1<<__LINK_STATE_DORMANT))) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) 		      (1<<__LINK_STATE_PRESENT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) 	if (vlan->flags & VLAN_FLAG_BRIDGE_BINDING)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) 		dev->state |= (1 << __LINK_STATE_NOCARRIER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) 	dev->hw_features = NETIF_F_HW_CSUM | NETIF_F_SG |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) 			   NETIF_F_FRAGLIST | NETIF_F_GSO_SOFTWARE |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) 			   NETIF_F_GSO_ENCAP_ALL |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) 			   NETIF_F_HIGHDMA | NETIF_F_SCTP_CRC |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) 			   NETIF_F_ALL_FCOE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) 	dev->features |= dev->hw_features | NETIF_F_LLTX;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) 	dev->gso_max_size = real_dev->gso_max_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) 	dev->gso_max_segs = real_dev->gso_max_segs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) 	if (dev->features & NETIF_F_VLAN_FEATURES)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) 		netdev_warn(real_dev, "VLAN features are set incorrectly.  Q-in-Q configurations may not work correctly.\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) 	dev->vlan_features = real_dev->vlan_features & ~NETIF_F_ALL_FCOE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) 	dev->hw_enc_features = vlan_tnl_features(real_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) 	dev->mpls_features = real_dev->mpls_features;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) 	/* ipv6 shared card related stuff */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) 	dev->dev_id = real_dev->dev_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) 	if (is_zero_ether_addr(dev->dev_addr)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) 		ether_addr_copy(dev->dev_addr, real_dev->dev_addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) 		dev->addr_assign_type = NET_ADDR_STOLEN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583) 	if (is_zero_ether_addr(dev->broadcast))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) 		memcpy(dev->broadcast, real_dev->broadcast, dev->addr_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) #if IS_ENABLED(CONFIG_FCOE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) 	dev->fcoe_ddp_xid = real_dev->fcoe_ddp_xid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590) 	dev->needed_headroom = real_dev->needed_headroom;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591) 	if (vlan_hw_offload_capable(real_dev->features, vlan->vlan_proto)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592) 		dev->header_ops      = &vlan_passthru_header_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) 		dev->hard_header_len = real_dev->hard_header_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) 		dev->header_ops      = &vlan_header_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) 		dev->hard_header_len = real_dev->hard_header_len + VLAN_HLEN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) 	dev->netdev_ops = &vlan_netdev_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) 	SET_NETDEV_DEVTYPE(dev, &vlan_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) 	vlan_dev_set_lockdep_class(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605) 	vlan->vlan_pcpu_stats = netdev_alloc_pcpu_stats(struct vlan_pcpu_stats);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606) 	if (!vlan->vlan_pcpu_stats)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) 	/* Get vlan's reference to real_dev */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610) 	dev_hold(real_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) /* Note: this function might be called multiple times for the same device. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616) void vlan_dev_uninit(struct net_device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) 	struct vlan_priority_tci_mapping *pm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619) 	struct vlan_dev_priv *vlan = vlan_dev_priv(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) 	int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622) 	for (i = 0; i < ARRAY_SIZE(vlan->egress_priority_map); i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) 		while ((pm = vlan->egress_priority_map[i]) != NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624) 			vlan->egress_priority_map[i] = pm->next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625) 			kfree(pm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630) static netdev_features_t vlan_dev_fix_features(struct net_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631) 	netdev_features_t features)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633) 	struct net_device *real_dev = vlan_dev_priv(dev)->real_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634) 	netdev_features_t old_features = features;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635) 	netdev_features_t lower_features;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637) 	lower_features = netdev_intersect_features((real_dev->vlan_features |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638) 						    NETIF_F_RXCSUM),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639) 						   real_dev->features);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641) 	/* Add HW_CSUM setting to preserve user ability to control
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642) 	 * checksum offload on the vlan device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644) 	if (lower_features & (NETIF_F_IP_CSUM|NETIF_F_IPV6_CSUM))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645) 		lower_features |= NETIF_F_HW_CSUM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646) 	features = netdev_intersect_features(features, lower_features);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647) 	features |= old_features & (NETIF_F_SOFT_FEATURES | NETIF_F_GSO_SOFTWARE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648) 	features |= NETIF_F_LLTX;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650) 	return features;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653) static int vlan_ethtool_get_link_ksettings(struct net_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654) 					   struct ethtool_link_ksettings *cmd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656) 	const struct vlan_dev_priv *vlan = vlan_dev_priv(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658) 	return __ethtool_get_link_ksettings(vlan->real_dev, cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661) static void vlan_ethtool_get_drvinfo(struct net_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662) 				     struct ethtool_drvinfo *info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664) 	strlcpy(info->driver, vlan_fullname, sizeof(info->driver));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665) 	strlcpy(info->version, vlan_version, sizeof(info->version));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666) 	strlcpy(info->fw_version, "N/A", sizeof(info->fw_version));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669) static int vlan_ethtool_get_ts_info(struct net_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670) 				    struct ethtool_ts_info *info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672) 	const struct vlan_dev_priv *vlan = vlan_dev_priv(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 673) 	const struct ethtool_ops *ops = vlan->real_dev->ethtool_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 674) 	struct phy_device *phydev = vlan->real_dev->phydev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 675) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 676) 	if (phy_has_tsinfo(phydev)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 677) 		return phy_ts_info(phydev, info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 678) 	} else if (ops->get_ts_info) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 679) 		return ops->get_ts_info(vlan->real_dev, info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 680) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 681) 		info->so_timestamping = SOF_TIMESTAMPING_RX_SOFTWARE |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 682) 			SOF_TIMESTAMPING_SOFTWARE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 683) 		info->phc_index = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 684) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 685) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 686) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 687) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 688) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 689) static void vlan_dev_get_stats64(struct net_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 690) 				 struct rtnl_link_stats64 *stats)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 691) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 692) 	struct vlan_pcpu_stats *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 693) 	u32 rx_errors = 0, tx_dropped = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 694) 	int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 695) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 696) 	for_each_possible_cpu(i) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 697) 		u64 rxpackets, rxbytes, rxmulticast, txpackets, txbytes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 698) 		unsigned int start;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 699) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 700) 		p = per_cpu_ptr(vlan_dev_priv(dev)->vlan_pcpu_stats, i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 701) 		do {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 702) 			start = u64_stats_fetch_begin_irq(&p->syncp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 703) 			rxpackets	= p->rx_packets;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 704) 			rxbytes		= p->rx_bytes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 705) 			rxmulticast	= p->rx_multicast;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 706) 			txpackets	= p->tx_packets;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 707) 			txbytes		= p->tx_bytes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 708) 		} while (u64_stats_fetch_retry_irq(&p->syncp, start));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 709) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 710) 		stats->rx_packets	+= rxpackets;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 711) 		stats->rx_bytes		+= rxbytes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 712) 		stats->multicast	+= rxmulticast;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 713) 		stats->tx_packets	+= txpackets;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 714) 		stats->tx_bytes		+= txbytes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 715) 		/* rx_errors & tx_dropped are u32 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 716) 		rx_errors	+= p->rx_errors;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 717) 		tx_dropped	+= p->tx_dropped;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 718) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 719) 	stats->rx_errors  = rx_errors;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 720) 	stats->tx_dropped = tx_dropped;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 721) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 722) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 723) #ifdef CONFIG_NET_POLL_CONTROLLER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 724) static void vlan_dev_poll_controller(struct net_device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 725) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 726) 	return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 727) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 728) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 729) static int vlan_dev_netpoll_setup(struct net_device *dev, struct netpoll_info *npinfo)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 730) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 731) 	struct vlan_dev_priv *vlan = vlan_dev_priv(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 732) 	struct net_device *real_dev = vlan->real_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 733) 	struct netpoll *netpoll;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 734) 	int err = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 735) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 736) 	netpoll = kzalloc(sizeof(*netpoll), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 737) 	err = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 738) 	if (!netpoll)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 739) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 740) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 741) 	err = __netpoll_setup(netpoll, real_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 742) 	if (err) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 743) 		kfree(netpoll);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 744) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 745) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 746) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 747) 	vlan->netpoll = netpoll;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 748) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 749) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 750) 	return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 751) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 752) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 753) static void vlan_dev_netpoll_cleanup(struct net_device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 754) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 755) 	struct vlan_dev_priv *vlan= vlan_dev_priv(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 756) 	struct netpoll *netpoll = vlan->netpoll;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 757) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 758) 	if (!netpoll)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 759) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 760) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 761) 	vlan->netpoll = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 762) 	__netpoll_free(netpoll);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 763) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 764) #endif /* CONFIG_NET_POLL_CONTROLLER */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 765) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 766) static int vlan_dev_get_iflink(const struct net_device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 767) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 768) 	struct net_device *real_dev = vlan_dev_priv(dev)->real_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 769) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 770) 	return real_dev->ifindex;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 771) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 772) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 773) static const struct ethtool_ops vlan_ethtool_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 774) 	.get_link_ksettings	= vlan_ethtool_get_link_ksettings,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 775) 	.get_drvinfo	        = vlan_ethtool_get_drvinfo,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 776) 	.get_link		= ethtool_op_get_link,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 777) 	.get_ts_info		= vlan_ethtool_get_ts_info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 778) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 779) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 780) static const struct net_device_ops vlan_netdev_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 781) 	.ndo_change_mtu		= vlan_dev_change_mtu,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 782) 	.ndo_init		= vlan_dev_init,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 783) 	.ndo_uninit		= vlan_dev_uninit,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 784) 	.ndo_open		= vlan_dev_open,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 785) 	.ndo_stop		= vlan_dev_stop,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 786) 	.ndo_start_xmit =  vlan_dev_hard_start_xmit,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 787) 	.ndo_validate_addr	= eth_validate_addr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 788) 	.ndo_set_mac_address	= vlan_dev_set_mac_address,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 789) 	.ndo_set_rx_mode	= vlan_dev_set_rx_mode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 790) 	.ndo_change_rx_flags	= vlan_dev_change_rx_flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 791) 	.ndo_do_ioctl		= vlan_dev_ioctl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 792) 	.ndo_neigh_setup	= vlan_dev_neigh_setup,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 793) 	.ndo_get_stats64	= vlan_dev_get_stats64,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 794) #if IS_ENABLED(CONFIG_FCOE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 795) 	.ndo_fcoe_ddp_setup	= vlan_dev_fcoe_ddp_setup,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 796) 	.ndo_fcoe_ddp_done	= vlan_dev_fcoe_ddp_done,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 797) 	.ndo_fcoe_enable	= vlan_dev_fcoe_enable,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 798) 	.ndo_fcoe_disable	= vlan_dev_fcoe_disable,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 799) 	.ndo_fcoe_ddp_target	= vlan_dev_fcoe_ddp_target,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 800) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 801) #ifdef NETDEV_FCOE_WWNN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 802) 	.ndo_fcoe_get_wwn	= vlan_dev_fcoe_get_wwn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 803) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 804) #ifdef CONFIG_NET_POLL_CONTROLLER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 805) 	.ndo_poll_controller	= vlan_dev_poll_controller,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 806) 	.ndo_netpoll_setup	= vlan_dev_netpoll_setup,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 807) 	.ndo_netpoll_cleanup	= vlan_dev_netpoll_cleanup,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 808) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 809) 	.ndo_fix_features	= vlan_dev_fix_features,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 810) 	.ndo_get_iflink		= vlan_dev_get_iflink,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 811) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 812) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 813) static void vlan_dev_free(struct net_device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 814) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 815) 	struct vlan_dev_priv *vlan = vlan_dev_priv(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 816) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 817) 	free_percpu(vlan->vlan_pcpu_stats);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 818) 	vlan->vlan_pcpu_stats = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 819) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 820) 	/* Get rid of the vlan's reference to real_dev */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 821) 	dev_put(vlan->real_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 822) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 823) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 824) void vlan_setup(struct net_device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 825) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 826) 	ether_setup(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 827) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 828) 	dev->priv_flags		|= IFF_802_1Q_VLAN | IFF_NO_QUEUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 829) 	dev->priv_flags		|= IFF_UNICAST_FLT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 830) 	dev->priv_flags		&= ~IFF_TX_SKB_SHARING;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 831) 	netif_keep_dst(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 832) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 833) 	dev->netdev_ops		= &vlan_netdev_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 834) 	dev->needs_free_netdev	= true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 835) 	dev->priv_destructor	= vlan_dev_free;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 836) 	dev->ethtool_ops	= &vlan_ethtool_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 837) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 838) 	dev->min_mtu		= 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 839) 	dev->max_mtu		= ETH_MAX_MTU;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 840) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 841) 	eth_zero_addr(dev->broadcast);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 842) }