xref: /linux/drivers/net/wireless/purelifi/plfxlc/chip.h (revision dec1c62e91ba268ab2a6e339d4d7a59287d5eba1)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * Copyright (c) 2021 pureLiFi
4  */
5 
6 #ifndef PLFXLC_CHIP_H
7 #define PLFXLC_CHIP_H
8 
9 #include <net/mac80211.h>
10 
11 #include "usb.h"
12 
13 enum unit_type {
14 	STA = 0,
15 	AP = 1,
16 };
17 
18 enum {
19 	PLFXLC_RADIO_OFF = 0,
20 	PLFXLC_RADIO_ON = 1,
21 };
22 
23 struct plfxlc_chip {
24 	struct plfxlc_usb usb;
25 	struct mutex mutex; /* lock to protect chip data */
26 	enum unit_type unit_type;
27 	u16 link_led;
28 	u8 beacon_set;
29 	u16 beacon_interval;
30 };
31 
32 struct plfxlc_mc_hash {
33 	u32 low;
34 	u32 high;
35 };
36 
37 #define plfxlc_chip_dev(chip) (&(chip)->usb.intf->dev)
38 
39 void plfxlc_chip_init(struct plfxlc_chip *chip,
40 		      struct ieee80211_hw *hw,
41 		      struct usb_interface *intf);
42 
43 void plfxlc_chip_release(struct plfxlc_chip *chip);
44 
45 void plfxlc_chip_disable_rxtx(struct plfxlc_chip *chip);
46 
47 int plfxlc_chip_init_hw(struct plfxlc_chip *chip);
48 
49 int plfxlc_chip_enable_rxtx(struct plfxlc_chip *chip);
50 
51 int plfxlc_chip_set_rate(struct plfxlc_chip *chip, u8 rate);
52 
53 int plfxlc_set_beacon_interval(struct plfxlc_chip *chip, u16 interval,
54 			       u8 dtim_period, int type);
55 
56 int plfxlc_chip_switch_radio(struct plfxlc_chip *chip, u16 value);
57 
58 static inline struct plfxlc_chip *plfxlc_usb_to_chip(struct plfxlc_usb
59 							 *usb)
60 {
61 	return container_of(usb, struct plfxlc_chip, usb);
62 }
63 
64 static inline void plfxlc_mc_add_all(struct plfxlc_mc_hash *hash)
65 {
66 	hash->low  = 0xffffffff;
67 	hash->high = 0xffffffff;
68 }
69 
70 #endif /* PLFXLC_CHIP_H */
71