1*b1906ceaSLachlan Hodges /* SPDX-License-Identifier: GPL-2.0-only */
2*b1906ceaSLachlan Hodges /*
3*b1906ceaSLachlan Hodges * Copyright (c) 2017-2026 Morse Micro
4*b1906ceaSLachlan Hodges */
5*b1906ceaSLachlan Hodges
6*b1906ceaSLachlan Hodges #ifndef _MM81X_MAC_H_
7*b1906ceaSLachlan Hodges #define _MM81X_MAC_H_
8*b1906ceaSLachlan Hodges
9*b1906ceaSLachlan Hodges #include "core.h"
10*b1906ceaSLachlan Hodges #include "command.h"
11*b1906ceaSLachlan Hodges
12*b1906ceaSLachlan Hodges struct mm81x_queue_params {
13*b1906ceaSLachlan Hodges u8 uapsd;
14*b1906ceaSLachlan Hodges u8 aci;
15*b1906ceaSLachlan Hodges u8 aifs;
16*b1906ceaSLachlan Hodges u16 cw_min;
17*b1906ceaSLachlan Hodges u16 cw_max;
18*b1906ceaSLachlan Hodges u32 txop;
19*b1906ceaSLachlan Hodges };
20*b1906ceaSLachlan Hodges
mm81x_vif_generate_cssid(struct ieee80211_vif * vif)21*b1906ceaSLachlan Hodges static inline u32 mm81x_vif_generate_cssid(struct ieee80211_vif *vif)
22*b1906ceaSLachlan Hodges {
23*b1906ceaSLachlan Hodges return mm81x_generate_cssid(vif->cfg.ssid, vif->cfg.ssid_len);
24*b1906ceaSLachlan Hodges }
25*b1906ceaSLachlan Hodges
26*b1906ceaSLachlan Hodges /*
27*b1906ceaSLachlan Hodges * Build a little-endian word from the last four octets of a MAC address;
28*b1906ceaSLachlan Hodges * the first two octets are dropped.
29*b1906ceaSLachlan Hodges */
mac2le32(const unsigned char * addr)30*b1906ceaSLachlan Hodges static inline __le32 mac2le32(const unsigned char *addr)
31*b1906ceaSLachlan Hodges {
32*b1906ceaSLachlan Hodges return cpu_to_le32(((u32)(addr[2]) << 24) | ((u32)(addr[3]) << 16) |
33*b1906ceaSLachlan Hodges ((u32)(addr[4]) << 8) | ((u32)(addr[5])));
34*b1906ceaSLachlan Hodges }
35*b1906ceaSLachlan Hodges
36*b1906ceaSLachlan Hodges static inline struct ieee80211_vif *
mm81x_rcu_dereference_vif_id(struct mm81x * mors,u8 vif_id,bool rcu)37*b1906ceaSLachlan Hodges mm81x_rcu_dereference_vif_id(struct mm81x *mors, u8 vif_id, bool rcu)
38*b1906ceaSLachlan Hodges {
39*b1906ceaSLachlan Hodges if (WARN_ON(vif_id >= ARRAY_SIZE(mors->vifs)))
40*b1906ceaSLachlan Hodges return NULL;
41*b1906ceaSLachlan Hodges
42*b1906ceaSLachlan Hodges if (rcu)
43*b1906ceaSLachlan Hodges return rcu_dereference(mors->vifs[vif_id]);
44*b1906ceaSLachlan Hodges
45*b1906ceaSLachlan Hodges return rcu_dereference_protected(mors->vifs[vif_id],
46*b1906ceaSLachlan Hodges lockdep_is_held(&mors->hw->wiphy->mtx));
47*b1906ceaSLachlan Hodges }
48*b1906ceaSLachlan Hodges
49*b1906ceaSLachlan Hodges int mm81x_tx_h_get_attempts(struct mm81x *mors,
50*b1906ceaSLachlan Hodges struct mm81x_skb_tx_status *tx_sts);
51*b1906ceaSLachlan Hodges struct mm81x *mm81x_mac_alloc(size_t priv_size, struct device *dev);
52*b1906ceaSLachlan Hodges int mm81x_mac_register(struct mm81x *mors);
53*b1906ceaSLachlan Hodges void mm81x_mac_free(struct mm81x *mors);
54*b1906ceaSLachlan Hodges void mm81x_mac_unregister(struct mm81x *mors);
55*b1906ceaSLachlan Hodges int mm81x_mac_event_recv(struct mm81x *mors, struct sk_buff *skb);
56*b1906ceaSLachlan Hodges void mm81x_mac_rx_skb(struct mm81x *mors, struct sk_buff *skb,
57*b1906ceaSLachlan Hodges struct mm81x_skb_rx_status *hdr_rx_status);
58*b1906ceaSLachlan Hodges void mm81x_mac_beacon_irq_handle(struct mm81x *mors, u32 status);
59*b1906ceaSLachlan Hodges
60*b1906ceaSLachlan Hodges u8 *mm81x_hw_scan_h_insert_tlvs(struct mm81x_hw_scan_params *params, u8 *buf);
61*b1906ceaSLachlan Hodges size_t mm81x_hw_scan_h_get_cmd_size(struct mm81x_hw_scan_params *params);
62*b1906ceaSLachlan Hodges void mm81x_tx_h_check_aggr(struct ieee80211_sta *pubsta, struct sk_buff *skb);
63*b1906ceaSLachlan Hodges #endif /* !_MM81X_MAC_H_ */
64