net/mac802154/driver-ops.h

Source file repositories/reference/linux-study-clean/net/mac802154/driver-ops.h

File Facts

System
Linux kernel
Corpus path
net/mac802154/driver-ops.h
Extension
.h
Size
8038 bytes
Lines
355
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

if (local->hw.flags & IEEE802154_HW_PROMISCUOUS) {
			ret = drv_set_promiscuous_mode(local, true);
			if (ret < 0)
				return ret;
		} else {
			return -EOPNOTSUPP;
		}

		/* In practice other filtering levels can be requested, but as
		 * for now most hardware/drivers only support
		 * IEEE802154_FILTERING_NONE, we fallback to this actual
		 * filtering level in hardware and make our own additional
		 * filtering in mac802154 receive path.
		 *
		 * TODO: Move this logic to the device drivers as hardware may
		 * support more higher level filters. Hardware may also require
		 * a different order how register are set, which could currently
		 * be buggy, so all received parameters need to be moved to the
		 * start() callback and let the driver go into the mode before
		 * it will turn on receive handling.
		 */
		local->phy->filtering = IEEE802154_FILTERING_NONE;
		break;
	case IEEE802154_FILTERING_4_FRAME_FIELDS:
		/* Do not error out if IEEE802154_HW_PROMISCUOUS because we
		 * expect the hardware to operate at the level
		 * IEEE802154_FILTERING_4_FRAME_FIELDS anyway.
		 */
		if (local->hw.flags & IEEE802154_HW_PROMISCUOUS) {
			ret = drv_set_promiscuous_mode(local, false);
			if (ret < 0)
				return ret;
		}

		local->phy->filtering = IEEE802154_FILTERING_4_FRAME_FIELDS;
		break;
	default:
		WARN_ON(1);
		return -EINVAL;
	}

	trace_802154_drv_start(local);
	local->started = true;
	smp_mb();
	ret = local->ops->start(&local->hw);
	trace_802154_drv_return_int(local, ret);
	return ret;
}

static inline void drv_stop(struct ieee802154_local *local)
{
	might_sleep();

	trace_802154_drv_stop(local);
	local->ops->stop(&local->hw);
	trace_802154_drv_return_void(local);

	/* sync away all work on the tasklet before clearing started */
	tasklet_disable(&local->tasklet);
	tasklet_enable(&local->tasklet);

	barrier();

	local->started = false;
}

static inline int
drv_set_channel(struct ieee802154_local *local, u8 page, u8 channel)
{
	int ret;

	might_sleep();

	trace_802154_drv_set_channel(local, page, channel);
	ret = local->ops->set_channel(&local->hw, page, channel);
	trace_802154_drv_return_int(local, ret);
	return ret;
}

static inline int drv_set_tx_power(struct ieee802154_local *local, s32 mbm)
{
	int ret;

	might_sleep();

	if (!local->ops->set_txpower) {
		WARN_ON(1);
		return -EOPNOTSUPP;
	}

Annotation

Implementation Notes