drivers/net/wireless/silabs/wfx/hif_tx_mib.c

Source file repositories/reference/linux-study-clean/drivers/net/wireless/silabs/wfx/hif_tx_mib.c

File Facts

System
Linux kernel
Corpus path
drivers/net/wireless/silabs/wfx/hif_tx_mib.c
Extension
.c
Size
8953 bytes
Lines
308
Domain
Driver Families
Bucket
drivers/net
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

// SPDX-License-Identifier: GPL-2.0-only
/*
 * Implementation of the host-to-chip MIBs of the hardware API.
 *
 * Copyright (c) 2017-2020, Silicon Laboratories, Inc.
 * Copyright (c) 2010, ST-Ericsson
 * Copyright (C) 2010, ST-Ericsson SA
 */

#include <linux/etherdevice.h>

#include "wfx.h"
#include "hif_tx.h"
#include "hif_tx_mib.h"
#include "hif_api_mib.h"

int wfx_hif_set_output_power(struct wfx_vif *wvif, int val)
{
	struct wfx_hif_mib_current_tx_power_level arg = {
		.power_level = cpu_to_le32(val * 10),
	};

	return wfx_hif_write_mib(wvif->wdev, wvif->id, HIF_MIB_ID_CURRENT_TX_POWER_LEVEL,
				 &arg, sizeof(arg));
}

int wfx_hif_set_beacon_wakeup_period(struct wfx_vif *wvif,
				     unsigned int dtim_interval, unsigned int listen_interval)
{
	struct wfx_hif_mib_beacon_wake_up_period arg = {
		.wakeup_period_min = dtim_interval,
		.receive_dtim = 0,
		.wakeup_period_max = listen_interval,
	};

	if (dtim_interval > 0xFF || listen_interval > 0xFFFF)
		return -EINVAL;
	return wfx_hif_write_mib(wvif->wdev, wvif->id, HIF_MIB_ID_BEACON_WAKEUP_PERIOD,
				 &arg, sizeof(arg));
}

int wfx_hif_set_rcpi_rssi_threshold(struct wfx_vif *wvif, int rssi_thold, int rssi_hyst)
{
	struct wfx_hif_mib_rcpi_rssi_threshold arg = {
		.rolling_average_count = 8,
		.detection = 1,
	};

	if (!rssi_thold && !rssi_hyst) {
		arg.upperthresh = 1;
		arg.lowerthresh = 1;
	} else {
		arg.upper_threshold = rssi_thold + rssi_hyst;
		arg.upper_threshold = (arg.upper_threshold + 110) * 2;
		arg.lower_threshold = rssi_thold;
		arg.lower_threshold = (arg.lower_threshold + 110) * 2;
	}

	return wfx_hif_write_mib(wvif->wdev, wvif->id, HIF_MIB_ID_RCPI_RSSI_THRESHOLD,
				 &arg, sizeof(arg));
}

int wfx_hif_get_counters_table(struct wfx_dev *wdev, int vif_id,
			       struct wfx_hif_mib_extended_count_table *arg)
{
	if (wfx_api_older_than(wdev, 1, 3)) {
		/* extended_count_table is wider than count_table */
		memset(arg, 0xFF, sizeof(*arg));
		return wfx_hif_read_mib(wdev, vif_id, HIF_MIB_ID_COUNTERS_TABLE,
				    arg, sizeof(struct wfx_hif_mib_count_table));
	} else {
		return wfx_hif_read_mib(wdev, vif_id, HIF_MIB_ID_EXTENDED_COUNTERS_TABLE,
					arg, sizeof(struct wfx_hif_mib_extended_count_table));
	}
}

int wfx_hif_set_macaddr(struct wfx_vif *wvif, u8 *mac)
{
	struct wfx_hif_mib_mac_address arg = { };

	if (mac)
		ether_addr_copy(arg.mac_addr, mac);
	return wfx_hif_write_mib(wvif->wdev, wvif->id, HIF_MIB_ID_DOT11_MAC_ADDRESS,
				 &arg, sizeof(arg));
}

int wfx_hif_set_rx_filter(struct wfx_vif *wvif, bool filter_bssid, bool filter_prbreq)
{
	struct wfx_hif_mib_rx_filter arg = { };

Annotation

Implementation Notes