1 // SPDX-License-Identifier: GPL-2.0
3 * WUSB cluster reservation management
5 * Copyright (C) 2007 Cambridge Silicon Radio Ltd.
7 #include <linux/kernel.h>
13 * WUSB cluster reservations are multicast reservations with the
14 * broadcast cluster ID (BCID) as the target DevAddr.
16 * FIXME: consider adjusting the reservation depending on what devices
20 static int wusbhc_bwa_set(struct wusbhc
*wusbhc
, u8 stream
,
21 const struct uwb_mas_bm
*mas
)
24 mas
= &uwb_mas_bm_zero
;
25 return wusbhc
->bwa_set(wusbhc
, stream
, mas
);
29 * wusbhc_rsv_complete_cb - WUSB HC reservation complete callback
30 * @rsv: the reservation
32 * Either set or clear the HC's view of the reservation.
34 * FIXME: when a reservation is denied the HC should be stopped.
36 static void wusbhc_rsv_complete_cb(struct uwb_rsv
*rsv
)
38 struct wusbhc
*wusbhc
= rsv
->pal_priv
;
39 struct device
*dev
= wusbhc
->dev
;
40 struct uwb_mas_bm mas
;
42 dev_dbg(dev
, "%s: state = %d\n", __func__
, rsv
->state
);
44 case UWB_RSV_STATE_O_ESTABLISHED
:
45 uwb_rsv_get_usable_mas(rsv
, &mas
);
46 dev_dbg(dev
, "established reservation: %*pb\n",
48 wusbhc_bwa_set(wusbhc
, rsv
->stream
, &mas
);
50 case UWB_RSV_STATE_NONE
:
51 dev_dbg(dev
, "removed reservation\n");
52 wusbhc_bwa_set(wusbhc
, 0, NULL
);
55 dev_dbg(dev
, "unexpected reservation state: %d\n", rsv
->state
);
62 * wusbhc_rsv_establish - establish a reservation for the cluster
63 * @wusbhc: the WUSB HC requesting a bandwidth reservation
65 int wusbhc_rsv_establish(struct wusbhc
*wusbhc
)
67 struct uwb_rc
*rc
= wusbhc
->uwb_rc
;
69 struct uwb_dev_addr bcid
;
75 rsv
= uwb_rsv_create(rc
, wusbhc_rsv_complete_cb
, wusbhc
);
79 bcid
.data
[0] = wusbhc
->cluster_id
;
82 rsv
->target
.type
= UWB_RSV_TARGET_DEVADDR
;
83 rsv
->target
.devaddr
= bcid
;
84 rsv
->type
= UWB_DRP_TYPE_PRIVATE
;
85 rsv
->max_mas
= 256; /* try to get as much as possible */
86 rsv
->min_mas
= 15; /* one MAS per zone */
87 rsv
->max_interval
= 1; /* max latency is one zone */
88 rsv
->is_multicast
= true;
90 ret
= uwb_rsv_establish(rsv
);
100 * wusbhc_rsv_terminate - terminate the cluster reservation
101 * @wusbhc: the WUSB host whose reservation is to be terminated
103 void wusbhc_rsv_terminate(struct wusbhc
*wusbhc
)
106 uwb_rsv_terminate(wusbhc
->rsv
);
107 uwb_rsv_destroy(wusbhc
->rsv
);