hc
2024-05-10 23fa18eaa71266feff7ba8d83022d9e1cc83c65a
kernel/include/linux/etherdevice.h
....@@ -1,3 +1,4 @@
1
+/* SPDX-License-Identifier: GPL-2.0-or-later */
12 /*
23 * INET An implementation of the TCP/IP protocol suite for the LINUX
34 * operating system. NET is implemented using the BSD Socket
....@@ -12,12 +13,6 @@
1213 *
1314 * Relocated to include/linux where it belongs by Alan Cox
1415 * <gw4pts@gw4pts.ampr.org>
15
- *
16
- * This program is free software; you can redistribute it and/or
17
- * modify it under the terms of the GNU General Public License
18
- * as published by the Free Software Foundation; either version
19
- * 2 of the License, or (at your option) any later version.
20
- *
2116 */
2217 #ifndef _LINUX_ETHERDEVICE_H
2318 #define _LINUX_ETHERDEVICE_H
....@@ -25,6 +20,7 @@
2520 #include <linux/if_ether.h>
2621 #include <linux/netdevice.h>
2722 #include <linux/random.h>
23
+#include <linux/crc32.h>
2824 #include <asm/unaligned.h>
2925 #include <asm/bitsperlong.h>
3026
....@@ -32,7 +28,8 @@
3228 struct device;
3329 int eth_platform_get_mac_address(struct device *dev, u8 *mac_addr);
3430 unsigned char *arch_get_platform_mac_address(void);
35
-u32 eth_get_headlen(void *data, unsigned int max_len);
31
+int nvmem_get_mac_address(struct device *dev, void *addrbuf);
32
+u32 eth_get_headlen(const struct net_device *dev, void *data, unsigned int len);
3633 __be16 eth_type_trans(struct sk_buff *skb, struct net_device *dev);
3734 extern const struct header_ops eth_header_ops;
3835
....@@ -43,10 +40,10 @@
4340 __be16 type);
4441 void eth_header_cache_update(struct hh_cache *hh, const struct net_device *dev,
4542 const unsigned char *haddr);
43
+__be16 eth_header_parse_protocol(const struct sk_buff *skb);
4644 int eth_prepare_mac_addr_change(struct net_device *dev, void *p);
4745 void eth_commit_mac_addr_change(struct net_device *dev, void *p);
4846 int eth_mac_addr(struct net_device *dev, void *p);
49
-int eth_change_mtu(struct net_device *dev, int new_mtu);
5047 int eth_validate_addr(struct net_device *dev);
5148
5249 struct net_device *alloc_etherdev_mqs(int sizeof_priv, unsigned int txqs,
....@@ -130,7 +127,7 @@
130127 #endif
131128 }
132129
133
-static inline bool is_multicast_ether_addr_64bits(const u8 addr[6+2])
130
+static inline bool is_multicast_ether_addr_64bits(const u8 *addr)
134131 {
135132 #if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) && BITS_PER_LONG == 64
136133 #ifdef __BIG_ENDIAN
....@@ -270,6 +267,17 @@
270267 }
271268
272269 /**
270
+ * eth_hw_addr_crc - Calculate CRC from netdev_hw_addr
271
+ * @ha: pointer to hardware address
272
+ *
273
+ * Calculate CRC from a hardware address as basis for filter hashes.
274
+ */
275
+static inline u32 eth_hw_addr_crc(struct netdev_hw_addr *ha)
276
+{
277
+ return ether_crc(ETH_ALEN, ha->addr);
278
+}
279
+
280
+/**
273281 * ether_addr_copy - Copy an Ethernet address
274282 * @dst: Pointer to a six-byte array Ethernet address destination
275283 * @src: Pointer to a six-byte array Ethernet address source
....@@ -289,6 +297,18 @@
289297 a[1] = b[1];
290298 a[2] = b[2];
291299 #endif
300
+}
301
+
302
+/**
303
+ * eth_hw_addr_set - Assign Ethernet address to a net_device
304
+ * @dev: pointer to net_device structure
305
+ * @addr: address to assign
306
+ *
307
+ * Assign given address to the net_device, addr_assign_type is not changed.
308
+ */
309
+static inline void eth_hw_addr_set(struct net_device *dev, const u8 *addr)
310
+{
311
+ ether_addr_copy(dev->dev_addr, addr);
292312 }
293313
294314 /**
....@@ -344,8 +364,7 @@
344364 * Please note that alignment of addr1 & addr2 are only guaranteed to be 16 bits.
345365 */
346366
347
-static inline bool ether_addr_equal_64bits(const u8 addr1[6+2],
348
- const u8 addr2[6+2])
367
+static inline bool ether_addr_equal_64bits(const u8 *addr1, const u8 *addr2)
349368 {
350369 #if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) && BITS_PER_LONG == 64
351370 u64 fold = (*(const u64 *)addr1) ^ (*(const u64 *)addr2);
....@@ -447,6 +466,18 @@
447466 }
448467
449468 /**
469
+ * eth_addr_inc() - Increment the given MAC address.
470
+ * @addr: Pointer to a six-byte array containing Ethernet address to increment.
471
+ */
472
+static inline void eth_addr_inc(u8 *addr)
473
+{
474
+ u64 u = ether_addr_to_u64(addr);
475
+
476
+ u++;
477
+ u64_to_ether_addr(u, addr);
478
+}
479
+
480
+/**
450481 * is_etherdev_addr - Tell if given Ethernet address belongs to the device.
451482 * @dev: Pointer to a device structure
452483 * @addr: Pointer to a six-byte array containing the Ethernet address