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-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  * Authors:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * (C) 2015 Pengutronix, Alexander Aring <aar@pengutronix.de>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  * Copyright (c)  2015 Nordic Semiconductor. All Rights Reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #include <net/6lowpan.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include "6lowpan_i.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #define LOWPAN_DEBUGFS_CTX_PFX_NUM_ARGS	8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) static struct dentry *lowpan_debugfs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) static int lowpan_ctx_flag_active_set(void *data, u64 val)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) 	struct lowpan_iphc_ctx *ctx = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 	if (val != 0 && val != 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 	if (val)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 		set_bit(LOWPAN_IPHC_CTX_FLAG_ACTIVE, &ctx->flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 		clear_bit(LOWPAN_IPHC_CTX_FLAG_ACTIVE, &ctx->flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) static int lowpan_ctx_flag_active_get(void *data, u64 *val)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 	*val = lowpan_iphc_ctx_is_active(data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) DEFINE_DEBUGFS_ATTRIBUTE(lowpan_ctx_flag_active_fops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 			 lowpan_ctx_flag_active_get,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 			 lowpan_ctx_flag_active_set, "%llu\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) static int lowpan_ctx_flag_c_set(void *data, u64 val)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 	struct lowpan_iphc_ctx *ctx = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 	if (val != 0 && val != 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 	if (val)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 		set_bit(LOWPAN_IPHC_CTX_FLAG_COMPRESSION, &ctx->flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 		clear_bit(LOWPAN_IPHC_CTX_FLAG_COMPRESSION, &ctx->flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) static int lowpan_ctx_flag_c_get(void *data, u64 *val)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	*val = lowpan_iphc_ctx_is_compression(data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 	return 0;
^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) DEFINE_DEBUGFS_ATTRIBUTE(lowpan_ctx_flag_c_fops, lowpan_ctx_flag_c_get,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 			 lowpan_ctx_flag_c_set, "%llu\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) static int lowpan_ctx_plen_set(void *data, u64 val)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	struct lowpan_iphc_ctx *ctx = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 	struct lowpan_iphc_ctx_table *t =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 		container_of(ctx, struct lowpan_iphc_ctx_table, table[ctx->id]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 	if (val > 128)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	spin_lock_bh(&t->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	ctx->plen = val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 	spin_unlock_bh(&t->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) static int lowpan_ctx_plen_get(void *data, u64 *val)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 	struct lowpan_iphc_ctx *ctx = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	struct lowpan_iphc_ctx_table *t =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 		container_of(ctx, struct lowpan_iphc_ctx_table, table[ctx->id]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	spin_lock_bh(&t->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	*val = ctx->plen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	spin_unlock_bh(&t->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) DEFINE_DEBUGFS_ATTRIBUTE(lowpan_ctx_plen_fops, lowpan_ctx_plen_get,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 			 lowpan_ctx_plen_set, "%llu\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) static int lowpan_ctx_pfx_show(struct seq_file *file, void *offset)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	struct lowpan_iphc_ctx *ctx = file->private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	struct lowpan_iphc_ctx_table *t =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 		container_of(ctx, struct lowpan_iphc_ctx_table, table[ctx->id]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 	spin_lock_bh(&t->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	seq_printf(file, "%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 		   be16_to_cpu(ctx->pfx.s6_addr16[0]),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 		   be16_to_cpu(ctx->pfx.s6_addr16[1]),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 		   be16_to_cpu(ctx->pfx.s6_addr16[2]),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 		   be16_to_cpu(ctx->pfx.s6_addr16[3]),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 		   be16_to_cpu(ctx->pfx.s6_addr16[4]),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 		   be16_to_cpu(ctx->pfx.s6_addr16[5]),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 		   be16_to_cpu(ctx->pfx.s6_addr16[6]),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 		   be16_to_cpu(ctx->pfx.s6_addr16[7]));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 	spin_unlock_bh(&t->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) static int lowpan_ctx_pfx_open(struct inode *inode, struct file *file)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 	return single_open(file, lowpan_ctx_pfx_show, inode->i_private);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) static ssize_t lowpan_ctx_pfx_write(struct file *fp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 				    const char __user *user_buf, size_t count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 				    loff_t *ppos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 	char buf[128] = {};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 	struct seq_file *file = fp->private_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 	struct lowpan_iphc_ctx *ctx = file->private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 	struct lowpan_iphc_ctx_table *t =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 		container_of(ctx, struct lowpan_iphc_ctx_table, table[ctx->id]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 	int status = count, n, i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 	unsigned int addr[8];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 	if (copy_from_user(&buf, user_buf, min_t(size_t, sizeof(buf) - 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 						 count))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 		status = -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 		goto out;
^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) 	n = sscanf(buf, "%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 		   &addr[0], &addr[1], &addr[2], &addr[3], &addr[4],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 		   &addr[5], &addr[6], &addr[7]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 	if (n != LOWPAN_DEBUGFS_CTX_PFX_NUM_ARGS) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 		status = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 	spin_lock_bh(&t->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 	for (i = 0; i < 8; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 		ctx->pfx.s6_addr16[i] = cpu_to_be16(addr[i] & 0xffff);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 	spin_unlock_bh(&t->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) static const struct file_operations lowpan_ctx_pfx_fops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 	.open		= lowpan_ctx_pfx_open,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 	.read		= seq_read,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 	.write		= lowpan_ctx_pfx_write,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 	.llseek		= seq_lseek,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 	.release	= single_release,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) static void lowpan_dev_debugfs_ctx_init(struct net_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 					struct dentry *ctx, u8 id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 	struct lowpan_dev *ldev = lowpan_dev(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 	struct dentry *root;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 	char buf[32];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 	if (WARN_ON_ONCE(id >= LOWPAN_IPHC_CTX_TABLE_SIZE))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 	sprintf(buf, "%d", id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 	root = debugfs_create_dir(buf, ctx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 	debugfs_create_file("active", 0644, root, &ldev->ctx.table[id],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 			    &lowpan_ctx_flag_active_fops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 	debugfs_create_file("compression", 0644, root, &ldev->ctx.table[id],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 			    &lowpan_ctx_flag_c_fops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 	debugfs_create_file("prefix", 0644, root, &ldev->ctx.table[id],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 			    &lowpan_ctx_pfx_fops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 	debugfs_create_file("prefix_len", 0644, root, &ldev->ctx.table[id],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 			    &lowpan_ctx_plen_fops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) static int lowpan_context_show(struct seq_file *file, void *offset)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 	struct lowpan_iphc_ctx_table *t = file->private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 	int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 	seq_printf(file, "%3s|%-43s|%c\n", "cid", "prefix", 'C');
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 	seq_puts(file, "-------------------------------------------------\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 	spin_lock_bh(&t->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 	for (i = 0; i < LOWPAN_IPHC_CTX_TABLE_SIZE; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 		if (!lowpan_iphc_ctx_is_active(&t->table[i]))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 			continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 		seq_printf(file, "%3d|%39pI6c/%-3d|%d\n", t->table[i].id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 			   &t->table[i].pfx, t->table[i].plen,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 			   lowpan_iphc_ctx_is_compression(&t->table[i]));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 	spin_unlock_bh(&t->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) DEFINE_SHOW_ATTRIBUTE(lowpan_context);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) static int lowpan_short_addr_get(void *data, u64 *val)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 	struct wpan_dev *wdev = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 	rtnl_lock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 	*val = le16_to_cpu(wdev->short_addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 	rtnl_unlock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) DEFINE_DEBUGFS_ATTRIBUTE(lowpan_short_addr_fops, lowpan_short_addr_get, NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 			 "0x%04llx\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) static void lowpan_dev_debugfs_802154_init(const struct net_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 					  struct lowpan_dev *ldev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 	struct dentry *root;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 	if (!lowpan_is_ll(dev, LOWPAN_LLTYPE_IEEE802154))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 	root = debugfs_create_dir("ieee802154", ldev->iface_debugfs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 	debugfs_create_file("short_addr", 0444, root,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 			    lowpan_802154_dev(dev)->wdev->ieee802154_ptr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 			    &lowpan_short_addr_fops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) void lowpan_dev_debugfs_init(struct net_device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 	struct lowpan_dev *ldev = lowpan_dev(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 	struct dentry *contexts;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 	int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 	/* creating the root */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 	ldev->iface_debugfs = debugfs_create_dir(dev->name, lowpan_debugfs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 	contexts = debugfs_create_dir("contexts", ldev->iface_debugfs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 	debugfs_create_file("show", 0644, contexts, &lowpan_dev(dev)->ctx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 			    &lowpan_context_fops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 	for (i = 0; i < LOWPAN_IPHC_CTX_TABLE_SIZE; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 		lowpan_dev_debugfs_ctx_init(dev, contexts, i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 	lowpan_dev_debugfs_802154_init(dev, ldev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) void lowpan_dev_debugfs_exit(struct net_device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 	debugfs_remove_recursive(lowpan_dev(dev)->iface_debugfs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) void __init lowpan_debugfs_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 	lowpan_debugfs = debugfs_create_dir("6lowpan", NULL);
^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) void lowpan_debugfs_exit(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 	debugfs_remove_recursive(lowpan_debugfs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) }