1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18#include <linux/kernel.h>
19#include <linux/uwb.h>
20
21#include "wusbhc.h"
22
23
24
25
26
27
28
29
30
31static int wusbhc_bwa_set(struct wusbhc *wusbhc, u8 stream,
32 const struct uwb_mas_bm *mas)
33{
34 if (mas == NULL)
35 mas = &uwb_mas_bm_zero;
36 return wusbhc->bwa_set(wusbhc, stream, mas);
37}
38
39
40
41
42
43
44
45
46
47static void wusbhc_rsv_complete_cb(struct uwb_rsv *rsv)
48{
49 struct wusbhc *wusbhc = rsv->pal_priv;
50 struct device *dev = wusbhc->dev;
51 struct uwb_mas_bm mas;
52
53 dev_dbg(dev, "%s: state = %d\n", __func__, rsv->state);
54 switch (rsv->state) {
55 case UWB_RSV_STATE_O_ESTABLISHED:
56 uwb_rsv_get_usable_mas(rsv, &mas);
57 dev_dbg(dev, "established reservation: %*pb\n",
58 UWB_NUM_MAS, mas.bm);
59 wusbhc_bwa_set(wusbhc, rsv->stream, &mas);
60 break;
61 case UWB_RSV_STATE_NONE:
62 dev_dbg(dev, "removed reservation\n");
63 wusbhc_bwa_set(wusbhc, 0, NULL);
64 break;
65 default:
66 dev_dbg(dev, "unexpected reservation state: %d\n", rsv->state);
67 break;
68 }
69}
70
71
72
73
74
75
76int wusbhc_rsv_establish(struct wusbhc *wusbhc)
77{
78 struct uwb_rc *rc = wusbhc->uwb_rc;
79 struct uwb_rsv *rsv;
80 struct uwb_dev_addr bcid;
81 int ret;
82
83 if (rc == NULL)
84 return -ENODEV;
85
86 rsv = uwb_rsv_create(rc, wusbhc_rsv_complete_cb, wusbhc);
87 if (rsv == NULL)
88 return -ENOMEM;
89
90 bcid.data[0] = wusbhc->cluster_id;
91 bcid.data[1] = 0;
92
93 rsv->target.type = UWB_RSV_TARGET_DEVADDR;
94 rsv->target.devaddr = bcid;
95 rsv->type = UWB_DRP_TYPE_PRIVATE;
96 rsv->max_mas = 256;
97 rsv->min_mas = 15;
98 rsv->max_interval = 1;
99 rsv->is_multicast = true;
100
101 ret = uwb_rsv_establish(rsv);
102 if (ret == 0)
103 wusbhc->rsv = rsv;
104 else
105 uwb_rsv_destroy(rsv);
106 return ret;
107}
108
109
110
111
112
113
114void wusbhc_rsv_terminate(struct wusbhc *wusbhc)
115{
116 if (wusbhc->rsv) {
117 uwb_rsv_terminate(wusbhc->rsv);
118 uwb_rsv_destroy(wusbhc->rsv);
119 wusbhc->rsv = NULL;
120 }
121}
122