net/mac80211/tests/s1g_tim.c

Source file repositories/reference/linux-study-clean/net/mac80211/tests/s1g_tim.c

File Facts

System
Linux kernel
Corpus path
net/mac80211/tests/s1g_tim.c
Extension
.c
Size
8841 bytes
Lines
357
Domain
Networking Core
Bucket
Sockets, Protocols, Packet Path, And Network Policy
Inferred role
Networking Core: implementation source
Status
source implementation candidate

Why This File Exists

Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.

Dependency Surface

Detected Declarations

Annotated Snippet

switch (mode) {
		case IEEE80211_S1G_TIM_ENC_MODE_BLOCK: {
			u8 blkmap = *ptr++;

			byte_to_bitstr(blkmap, bits);
			kunit_info(test, "  octet %2u (blk-map) : %s (0x%02x)",
				   oct, bits, blkmap);
			++oct;

			for (u8 sb = 0; sb < 8; sb++) {
				if (!(blkmap & BIT(sb)))
					continue;
				u8 sub = *ptr++;

				byte_to_bitstr(sub, bits);
				kunit_info(
					test,
					"  octet %2u (SB %2u)   : %s (0x%02x)",
					oct, sb, bits, sub);
				++oct;
			}
			break;
		}
		case IEEE80211_S1G_TIM_ENC_MODE_SINGLE: {
			u8 single = *ptr++;

			byte_to_bitstr(single, bits);
			kunit_info(test, "  octet %2u (single)  : %s (0x%02x)",
				   oct, bits, single);
			++oct;
			break;
		}
		case IEEE80211_S1G_TIM_ENC_MODE_OLB: {
			u8 len = *ptr++;

			byte_to_bitstr(len, bits);
			kunit_info(test, "  octet %2u (len=%2u)  : %s (0x%02x)",
				   oct, len, bits, len);
			++oct;

			for (u8 i = 0; i < len && ptr < end; i++) {
				u8 sub = *ptr++;

				byte_to_bitstr(sub, bits);
				kunit_info(
					test,
					"  octet %2u (SB %2u)   : %s (0x%02x)",
					oct, i, bits, sub);
				++oct;
			}
			break;
		}
		default:
			kunit_info(test, "  ** unknown encoding 0x%x **", mode);
			return;
		}
		blk++;
	}
}

static void tim_push(u8 **p, u8 v)
{
	*(*p)++ = v;
}

static void tim_begin(struct ieee80211_tim_ie *tim, u8 **p)
{
	tim->dtim_count = 0;
	tim->dtim_period = 1;
	tim->bitmap_ctrl = 0;
	*p = tim->virtual_map;
}

static u8 tim_end(struct ieee80211_tim_ie *tim, u8 *tail)
{
	return tail - (u8 *)tim;
}

static void pvb_add_block_bitmap(u8 **p, u8 blk_off, bool inverse, u8 blk_bmap,
				 const u8 *subblocks)
{
	u8 enc = IEEE80211_S1G_TIM_ENC_MODE_BLOCK;
	u8 n = hweight8(blk_bmap);

	tim_push(p, BC(enc, inverse, blk_off));
	tim_push(p, blk_bmap);

	for (u8 i = 0; i < n; i++)
		tim_push(p, subblocks[i]);
}

Annotation

Implementation Notes