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
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4) #include <linux/device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5) #include <linux/netdevice.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) #include <net/bonding.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) #include <net/bond_alb.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #if defined(CONFIG_DEBUG_FS) && !defined(CONFIG_NET_NS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include <linux/debugfs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <linux/seq_file.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) static struct dentry *bonding_debug_root;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) /* Show RLB hash table */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) static int bond_debug_rlb_hash_show(struct seq_file *m, void *v)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) 	struct bonding *bond = m->private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 	struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 	struct rlb_client_info *client_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 	u32 hash_index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 	if (BOND_MODE(bond) != BOND_MODE_ALB)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 	seq_printf(m, "SourceIP        DestinationIP   "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 			"Destination MAC   DEV\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 	spin_lock_bh(&bond->mode_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 	hash_index = bond_info->rx_hashtbl_used_head;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 	for (; hash_index != RLB_NULL_INDEX;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 	     hash_index = client_info->used_next) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 		client_info = &(bond_info->rx_hashtbl[hash_index]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 		seq_printf(m, "%-15pI4 %-15pI4 %-17pM %s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 			&client_info->ip_src,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 			&client_info->ip_dst,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 			&client_info->mac_dst,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 			client_info->slave->dev->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 	spin_unlock_bh(&bond->mode_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) DEFINE_SHOW_ATTRIBUTE(bond_debug_rlb_hash);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) void bond_debug_register(struct bonding *bond)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	if (!bonding_debug_root)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 	bond->debug_dir =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 		debugfs_create_dir(bond->dev->name, bonding_debug_root);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 	debugfs_create_file("rlb_hash_table", 0400, bond->debug_dir,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 				bond, &bond_debug_rlb_hash_fops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) void bond_debug_unregister(struct bonding *bond)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	if (!bonding_debug_root)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 	debugfs_remove_recursive(bond->debug_dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) void bond_debug_reregister(struct bonding *bond)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 	struct dentry *d;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	if (!bonding_debug_root)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 	d = debugfs_rename(bonding_debug_root, bond->debug_dir,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 			   bonding_debug_root, bond->dev->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	if (d) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 		bond->debug_dir = d;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 		netdev_warn(bond->dev, "failed to reregister, so just unregister old one\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 		bond_debug_unregister(bond);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) void bond_create_debugfs(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	bonding_debug_root = debugfs_create_dir("bonding", NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	if (!bonding_debug_root) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 		pr_warn("Warning: Cannot create bonding directory in debugfs\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) void bond_destroy_debugfs(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	debugfs_remove_recursive(bonding_debug_root);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	bonding_debug_root = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) #else /* !CONFIG_DEBUG_FS */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) void bond_debug_register(struct bonding *bond)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) void bond_debug_unregister(struct bonding *bond)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) void bond_debug_reregister(struct bonding *bond)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) void bond_create_debugfs(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) void bond_destroy_debugfs(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) #endif /* CONFIG_DEBUG_FS */