Merge tag 'csky-for-linus-5.7-rc1' of git://github.com/c-sky/csky-linux
[linux-2.6-microblaze.git] / drivers / staging / wfx / data_tx.h
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * Datapath implementation.
4  *
5  * Copyright (c) 2017-2019, Silicon Laboratories, Inc.
6  * Copyright (c) 2010, ST-Ericsson
7  */
8 #ifndef WFX_DATA_TX_H
9 #define WFX_DATA_TX_H
10
11 #include <linux/list.h>
12 #include <net/mac80211.h>
13
14 #include "hif_api_cmd.h"
15 #include "hif_api_mib.h"
16
17 struct wfx_tx_priv;
18 struct wfx_dev;
19 struct wfx_vif;
20
21 struct tx_policy {
22         struct list_head link;
23         int usage_count;
24         u8 rates[12];
25         bool uploaded;
26 };
27
28 struct tx_policy_cache {
29         struct tx_policy cache[HIF_MIB_NUM_TX_RATE_RETRY_POLICIES];
30         // FIXME: use a trees and drop hash from tx_policy
31         struct list_head used;
32         struct list_head free;
33         spinlock_t lock;
34 };
35
36 struct wfx_tx_priv {
37         ktime_t xmit_timestamp;
38         struct ieee80211_key_conf *hw_key;
39         u8 link_id;
40         u8 raw_link_id;
41 } __packed;
42
43 void wfx_tx_policy_init(struct wfx_vif *wvif);
44 void wfx_tx_policy_upload_work(struct work_struct *work);
45
46 void wfx_tx(struct ieee80211_hw *hw, struct ieee80211_tx_control *control,
47             struct sk_buff *skb);
48 void wfx_tx_confirm_cb(struct wfx_vif *wvif, const struct hif_cnf_tx *arg);
49 void wfx_skb_dtor(struct wfx_dev *wdev, struct sk_buff *skb);
50
51 static inline struct wfx_tx_priv *wfx_skb_tx_priv(struct sk_buff *skb)
52 {
53         struct ieee80211_tx_info *tx_info;
54
55         if (!skb)
56                 return NULL;
57         tx_info = IEEE80211_SKB_CB(skb);
58         return (struct wfx_tx_priv *)tx_info->rate_driver_data;
59 }
60
61 static inline struct hif_req_tx *wfx_skb_txreq(struct sk_buff *skb)
62 {
63         struct hif_msg *hif = (struct hif_msg *)skb->data;
64         struct hif_req_tx *req = (struct hif_req_tx *)hif->body;
65
66         return req;
67 }
68
69 #endif /* WFX_DATA_TX_H */