aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/uwb
diff options
context:
space:
mode:
authorThomas Pugliese <thomas.pugliese@gmail.com>2014-04-28 15:53:25 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-05-27 18:18:48 -0400
commitd339a1f2ff9b51bc195c6233978b1eb32164bbca (patch)
treea33caa3daf13f9dacc1c7632b138702af083f207 /drivers/uwb
parenta838ec7b0293ba0cdcda9b75cf428c93beea927c (diff)
uwb: whitespace and line length cleanups
Fix whitespace and line length issues reported by checkpatch. Signed-off-by: Thomas Pugliese <thomas.pugliese@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/uwb')
-rw-r--r--drivers/uwb/drp.c294
1 files changed, 166 insertions, 128 deletions
diff --git a/drivers/uwb/drp.c b/drivers/uwb/drp.c
index 468c89fb6a16..05b7bd762254 100644
--- a/drivers/uwb/drp.c
+++ b/drivers/uwb/drp.c
@@ -29,19 +29,19 @@
29enum uwb_drp_conflict_action { 29enum uwb_drp_conflict_action {
30 /* Reservation is maintained, no action needed */ 30 /* Reservation is maintained, no action needed */
31 UWB_DRP_CONFLICT_MANTAIN = 0, 31 UWB_DRP_CONFLICT_MANTAIN = 0,
32 32
33 /* the device shall not transmit frames in conflicting MASs in 33 /* the device shall not transmit frames in conflicting MASs in
34 * the following superframe. If the device is the reservation 34 * the following superframe. If the device is the reservation
35 * target, it shall also set the Reason Code in its DRP IE to 35 * target, it shall also set the Reason Code in its DRP IE to
36 * Conflict in its beacon in the following superframe. 36 * Conflict in its beacon in the following superframe.
37 */ 37 */
38 UWB_DRP_CONFLICT_ACT1, 38 UWB_DRP_CONFLICT_ACT1,
39 39
40 /* the device shall not set the Reservation Status bit to ONE 40 /* the device shall not set the Reservation Status bit to ONE
41 * and shall not transmit frames in conflicting MASs. If the 41 * and shall not transmit frames in conflicting MASs. If the
42 * device is the reservation target, it shall also set the 42 * device is the reservation target, it shall also set the
43 * Reason Code in its DRP IE to Conflict. 43 * Reason Code in its DRP IE to Conflict.
44 */ 44 */
45 UWB_DRP_CONFLICT_ACT2, 45 UWB_DRP_CONFLICT_ACT2,
46 46
47 /* the device shall not transmit frames in conflicting MASs in 47 /* the device shall not transmit frames in conflicting MASs in
@@ -115,7 +115,8 @@ int uwb_rc_send_all_drp_ie(struct uwb_rc *rc)
115 if (uwb_rsv_has_two_drp_ies(rsv) && 115 if (uwb_rsv_has_two_drp_ies(rsv) &&
116 (rsv->mv.companion_drp_ie != NULL)) { 116 (rsv->mv.companion_drp_ie != NULL)) {
117 mv = &rsv->mv; 117 mv = &rsv->mv;
118 num_bytes += mv->companion_drp_ie->hdr.length + 2; 118 num_bytes +=
119 mv->companion_drp_ie->hdr.length + 2;
119 } 120 }
120 } 121 }
121 } 122 }
@@ -139,21 +140,23 @@ int uwb_rc_send_all_drp_ie(struct uwb_rc *rc)
139 memcpy(IEDataptr, rsv->drp_ie, 140 memcpy(IEDataptr, rsv->drp_ie,
140 rsv->drp_ie->hdr.length + 2); 141 rsv->drp_ie->hdr.length + 2);
141 IEDataptr += rsv->drp_ie->hdr.length + 2; 142 IEDataptr += rsv->drp_ie->hdr.length + 2;
142 143
143 if (uwb_rsv_has_two_drp_ies(rsv) && 144 if (uwb_rsv_has_two_drp_ies(rsv) &&
144 (rsv->mv.companion_drp_ie != NULL)) { 145 (rsv->mv.companion_drp_ie != NULL)) {
145 mv = &rsv->mv; 146 mv = &rsv->mv;
146 memcpy(IEDataptr, mv->companion_drp_ie, 147 memcpy(IEDataptr, mv->companion_drp_ie,
147 mv->companion_drp_ie->hdr.length + 2); 148 mv->companion_drp_ie->hdr.length + 2);
148 IEDataptr += mv->companion_drp_ie->hdr.length + 2; 149 IEDataptr +=
150 mv->companion_drp_ie->hdr.length + 2;
149 } 151 }
150 } 152 }
151 } 153 }
152 154
153 result = uwb_rc_cmd_async(rc, "SET-DRP-IE", &cmd->rccb, sizeof(*cmd) + num_bytes, 155 result = uwb_rc_cmd_async(rc, "SET-DRP-IE",
154 UWB_RC_CET_GENERAL, UWB_RC_CMD_SET_DRP_IE, 156 &cmd->rccb, sizeof(*cmd) + num_bytes,
155 uwb_rc_set_drp_cmd_done, NULL); 157 UWB_RC_CET_GENERAL, UWB_RC_CMD_SET_DRP_IE,
156 158 uwb_rc_set_drp_cmd_done, NULL);
159
157 rc->set_drp_ie_pending = 1; 160 rc->set_drp_ie_pending = 1;
158 161
159 kfree(cmd); 162 kfree(cmd);
@@ -176,8 +179,8 @@ static int evaluate_conflict_action(struct uwb_ie_drp *ext_drp_ie, int ext_beaco
176 int ext_tie_breaker = uwb_ie_drp_tiebreaker(ext_drp_ie); 179 int ext_tie_breaker = uwb_ie_drp_tiebreaker(ext_drp_ie);
177 int ext_status = uwb_ie_drp_status(ext_drp_ie); 180 int ext_status = uwb_ie_drp_status(ext_drp_ie);
178 int ext_type = uwb_ie_drp_type(ext_drp_ie); 181 int ext_type = uwb_ie_drp_type(ext_drp_ie);
179 182
180 183
181 /* [ECMA-368 2nd Edition] 17.4.6 */ 184 /* [ECMA-368 2nd Edition] 17.4.6 */
182 if (ext_type == UWB_DRP_TYPE_PCA && our_type == UWB_DRP_TYPE_PCA) { 185 if (ext_type == UWB_DRP_TYPE_PCA && our_type == UWB_DRP_TYPE_PCA) {
183 return UWB_DRP_CONFLICT_MANTAIN; 186 return UWB_DRP_CONFLICT_MANTAIN;
@@ -187,7 +190,7 @@ static int evaluate_conflict_action(struct uwb_ie_drp *ext_drp_ie, int ext_beaco
187 if (our_type == UWB_DRP_TYPE_ALIEN_BP) { 190 if (our_type == UWB_DRP_TYPE_ALIEN_BP) {
188 return UWB_DRP_CONFLICT_MANTAIN; 191 return UWB_DRP_CONFLICT_MANTAIN;
189 } 192 }
190 193
191 /* [ECMA-368 2nd Edition] 17.4.6-2 */ 194 /* [ECMA-368 2nd Edition] 17.4.6-2 */
192 if (ext_type == UWB_DRP_TYPE_ALIEN_BP) { 195 if (ext_type == UWB_DRP_TYPE_ALIEN_BP) {
193 /* here we know our_type != UWB_DRP_TYPE_ALIEN_BP */ 196 /* here we know our_type != UWB_DRP_TYPE_ALIEN_BP */
@@ -215,7 +218,7 @@ static int evaluate_conflict_action(struct uwb_ie_drp *ext_drp_ie, int ext_beaco
215 our_beacon_slot > ext_beacon_slot) { 218 our_beacon_slot > ext_beacon_slot) {
216 return UWB_DRP_CONFLICT_MANTAIN; 219 return UWB_DRP_CONFLICT_MANTAIN;
217 } 220 }
218 221
219 if (our_status == 0) { 222 if (our_status == 0) {
220 if (our_tie_breaker == ext_tie_breaker) { 223 if (our_tie_breaker == ext_tie_breaker) {
221 /* [ECMA-368 2nd Edition] 17.4.6-6a */ 224 /* [ECMA-368 2nd Edition] 17.4.6-6a */
@@ -244,9 +247,9 @@ static int evaluate_conflict_action(struct uwb_ie_drp *ext_drp_ie, int ext_beaco
244 return UWB_DRP_CONFLICT_MANTAIN; 247 return UWB_DRP_CONFLICT_MANTAIN;
245} 248}
246 249
247static void handle_conflict_normal(struct uwb_ie_drp *drp_ie, 250static void handle_conflict_normal(struct uwb_ie_drp *drp_ie,
248 int ext_beacon_slot, 251 int ext_beacon_slot,
249 struct uwb_rsv *rsv, 252 struct uwb_rsv *rsv,
250 struct uwb_mas_bm *conflicting_mas) 253 struct uwb_mas_bm *conflicting_mas)
251{ 254{
252 struct uwb_rc *rc = rsv->rc; 255 struct uwb_rc *rc = rsv->rc;
@@ -263,7 +266,7 @@ static void handle_conflict_normal(struct uwb_ie_drp *drp_ie,
263 uwb_rsv_set_state(rsv, UWB_RSV_STATE_O_TO_BE_MOVED); 266 uwb_rsv_set_state(rsv, UWB_RSV_STATE_O_TO_BE_MOVED);
264 if (bow->can_reserve_extra_mases == false) 267 if (bow->can_reserve_extra_mases == false)
265 uwb_rsv_backoff_win_increment(rc); 268 uwb_rsv_backoff_win_increment(rc);
266 269
267 break; 270 break;
268 case UWB_DRP_CONFLICT_ACT3: 271 case UWB_DRP_CONFLICT_ACT3:
269 uwb_rsv_backoff_win_increment(rc); 272 uwb_rsv_backoff_win_increment(rc);
@@ -278,13 +281,13 @@ static void handle_conflict_normal(struct uwb_ie_drp *drp_ie,
278 switch(action) { 281 switch(action) {
279 case UWB_DRP_CONFLICT_ACT2: 282 case UWB_DRP_CONFLICT_ACT2:
280 case UWB_DRP_CONFLICT_ACT3: 283 case UWB_DRP_CONFLICT_ACT3:
281 uwb_rsv_set_state(rsv, UWB_RSV_STATE_T_CONFLICT); 284 uwb_rsv_set_state(rsv, UWB_RSV_STATE_T_CONFLICT);
282 default: 285 default:
283 break; 286 break;
284 } 287 }
285 288
286 } 289 }
287 290
288} 291}
289 292
290static void handle_conflict_expanding(struct uwb_ie_drp *drp_ie, int ext_beacon_slot, 293static void handle_conflict_expanding(struct uwb_ie_drp *drp_ie, int ext_beacon_slot,
@@ -295,7 +298,7 @@ static void handle_conflict_expanding(struct uwb_ie_drp *drp_ie, int ext_beacon_
295 struct uwb_drp_backoff_win *bow = &rc->bow; 298 struct uwb_drp_backoff_win *bow = &rc->bow;
296 struct uwb_rsv_move *mv = &rsv->mv; 299 struct uwb_rsv_move *mv = &rsv->mv;
297 int action; 300 int action;
298 301
299 if (companion_only) { 302 if (companion_only) {
300 /* status of companion is 0 at this point */ 303 /* status of companion is 0 at this point */
301 action = evaluate_conflict_action(drp_ie, ext_beacon_slot, rsv, 0); 304 action = evaluate_conflict_action(drp_ie, ext_beacon_slot, rsv, 0);
@@ -303,21 +306,24 @@ static void handle_conflict_expanding(struct uwb_ie_drp *drp_ie, int ext_beacon_
303 switch(action) { 306 switch(action) {
304 case UWB_DRP_CONFLICT_ACT2: 307 case UWB_DRP_CONFLICT_ACT2:
305 case UWB_DRP_CONFLICT_ACT3: 308 case UWB_DRP_CONFLICT_ACT3:
306 uwb_rsv_set_state(rsv, UWB_RSV_STATE_O_ESTABLISHED); 309 uwb_rsv_set_state(rsv,
310 UWB_RSV_STATE_O_ESTABLISHED);
307 rsv->needs_release_companion_mas = false; 311 rsv->needs_release_companion_mas = false;
308 if (bow->can_reserve_extra_mases == false) 312 if (bow->can_reserve_extra_mases == false)
309 uwb_rsv_backoff_win_increment(rc); 313 uwb_rsv_backoff_win_increment(rc);
310 uwb_drp_avail_release(rsv->rc, &rsv->mv.companion_mas); 314 uwb_drp_avail_release(rsv->rc,
315 &rsv->mv.companion_mas);
311 } 316 }
312 } else { /* rsv is target */ 317 } else { /* rsv is target */
313 switch(action) { 318 switch(action) {
314 case UWB_DRP_CONFLICT_ACT2: 319 case UWB_DRP_CONFLICT_ACT2:
315 case UWB_DRP_CONFLICT_ACT3: 320 case UWB_DRP_CONFLICT_ACT3:
316 uwb_rsv_set_state(rsv, UWB_RSV_STATE_T_EXPANDING_CONFLICT); 321 uwb_rsv_set_state(rsv,
322 UWB_RSV_STATE_T_EXPANDING_CONFLICT);
317 /* send_drp_avail_ie = true; */ 323 /* send_drp_avail_ie = true; */
318 } 324 }
319 } 325 }
320 } else { /* also base part of the reservation is conflicting */ 326 } else { /* also base part of the reservation is conflicting */
321 if (uwb_rsv_is_owner(rsv)) { 327 if (uwb_rsv_is_owner(rsv)) {
322 uwb_rsv_backoff_win_increment(rc); 328 uwb_rsv_backoff_win_increment(rc);
323 /* remove companion part */ 329 /* remove companion part */
@@ -326,7 +332,8 @@ static void handle_conflict_expanding(struct uwb_ie_drp *drp_ie, int ext_beacon_
326 /* drop some mases with reason modified */ 332 /* drop some mases with reason modified */
327 333
328 /* put in the companion the mases to be dropped */ 334 /* put in the companion the mases to be dropped */
329 bitmap_andnot(mv->companion_mas.bm, rsv->mas.bm, conflicting_mas->bm, UWB_NUM_MAS); 335 bitmap_andnot(mv->companion_mas.bm, rsv->mas.bm,
336 conflicting_mas->bm, UWB_NUM_MAS);
330 uwb_rsv_set_state(rsv, UWB_RSV_STATE_O_MODIFIED); 337 uwb_rsv_set_state(rsv, UWB_RSV_STATE_O_MODIFIED);
331 } else { /* it is a target rsv */ 338 } else { /* it is a target rsv */
332 uwb_rsv_set_state(rsv, UWB_RSV_STATE_T_CONFLICT); 339 uwb_rsv_set_state(rsv, UWB_RSV_STATE_T_CONFLICT);
@@ -336,7 +343,7 @@ static void handle_conflict_expanding(struct uwb_ie_drp *drp_ie, int ext_beacon_
336} 343}
337 344
338static void uwb_drp_handle_conflict_rsv(struct uwb_rc *rc, struct uwb_rsv *rsv, 345static void uwb_drp_handle_conflict_rsv(struct uwb_rc *rc, struct uwb_rsv *rsv,
339 struct uwb_rc_evt_drp *drp_evt, 346 struct uwb_rc_evt_drp *drp_evt,
340 struct uwb_ie_drp *drp_ie, 347 struct uwb_ie_drp *drp_ie,
341 struct uwb_mas_bm *conflicting_mas) 348 struct uwb_mas_bm *conflicting_mas)
342{ 349{
@@ -345,83 +352,107 @@ static void uwb_drp_handle_conflict_rsv(struct uwb_rc *rc, struct uwb_rsv *rsv,
345 /* check if the conflicting reservation has two drp_ies */ 352 /* check if the conflicting reservation has two drp_ies */
346 if (uwb_rsv_has_two_drp_ies(rsv)) { 353 if (uwb_rsv_has_two_drp_ies(rsv)) {
347 mv = &rsv->mv; 354 mv = &rsv->mv;
348 if (bitmap_intersects(rsv->mas.bm, conflicting_mas->bm, UWB_NUM_MAS)) { 355 if (bitmap_intersects(rsv->mas.bm, conflicting_mas->bm,
349 handle_conflict_expanding(drp_ie, drp_evt->beacon_slot_number, 356 UWB_NUM_MAS)) {
350 rsv, false, conflicting_mas); 357 handle_conflict_expanding(drp_ie,
358 drp_evt->beacon_slot_number,
359 rsv, false, conflicting_mas);
351 } else { 360 } else {
352 if (bitmap_intersects(mv->companion_mas.bm, conflicting_mas->bm, UWB_NUM_MAS)) { 361 if (bitmap_intersects(mv->companion_mas.bm,
353 handle_conflict_expanding(drp_ie, drp_evt->beacon_slot_number, 362 conflicting_mas->bm, UWB_NUM_MAS)) {
354 rsv, true, conflicting_mas); 363 handle_conflict_expanding(
364 drp_ie, drp_evt->beacon_slot_number,
365 rsv, true, conflicting_mas);
355 } 366 }
356 } 367 }
357 } else if (bitmap_intersects(rsv->mas.bm, conflicting_mas->bm, UWB_NUM_MAS)) { 368 } else if (bitmap_intersects(rsv->mas.bm, conflicting_mas->bm,
358 handle_conflict_normal(drp_ie, drp_evt->beacon_slot_number, rsv, conflicting_mas); 369 UWB_NUM_MAS)) {
370 handle_conflict_normal(drp_ie, drp_evt->beacon_slot_number,
371 rsv, conflicting_mas);
359 } 372 }
360} 373}
361 374
362static void uwb_drp_handle_all_conflict_rsv(struct uwb_rc *rc, 375static void uwb_drp_handle_all_conflict_rsv(struct uwb_rc *rc,
363 struct uwb_rc_evt_drp *drp_evt, 376 struct uwb_rc_evt_drp *drp_evt,
364 struct uwb_ie_drp *drp_ie, 377 struct uwb_ie_drp *drp_ie,
365 struct uwb_mas_bm *conflicting_mas) 378 struct uwb_mas_bm *conflicting_mas)
366{ 379{
367 struct uwb_rsv *rsv; 380 struct uwb_rsv *rsv;
368 381
369 list_for_each_entry(rsv, &rc->reservations, rc_node) { 382 list_for_each_entry(rsv, &rc->reservations, rc_node) {
370 uwb_drp_handle_conflict_rsv(rc, rsv, drp_evt, drp_ie, conflicting_mas); 383 uwb_drp_handle_conflict_rsv(rc, rsv, drp_evt, drp_ie,
384 conflicting_mas);
385 }
386}
387
388static void uwb_drp_process_target_accepted(struct uwb_rc *rc,
389 struct uwb_rsv *rsv, struct uwb_rc_evt_drp *drp_evt,
390 struct uwb_ie_drp *drp_ie, struct uwb_mas_bm *mas)
391{
392 struct uwb_rsv_move *mv = &rsv->mv;
393 int status;
394
395 status = uwb_ie_drp_status(drp_ie);
396
397 if (rsv->state == UWB_RSV_STATE_T_CONFLICT) {
398 uwb_rsv_set_state(rsv, UWB_RSV_STATE_T_CONFLICT);
399 return;
400 }
401
402 if (rsv->state == UWB_RSV_STATE_T_EXPANDING_ACCEPTED) {
403 /* drp_ie is companion */
404 if (!bitmap_equal(rsv->mas.bm, mas->bm, UWB_NUM_MAS)) {
405 /* stroke companion */
406 uwb_rsv_set_state(rsv,
407 UWB_RSV_STATE_T_EXPANDING_ACCEPTED);
408 }
409 } else {
410 if (!bitmap_equal(rsv->mas.bm, mas->bm, UWB_NUM_MAS)) {
411 if (uwb_drp_avail_reserve_pending(rc, mas) == -EBUSY) {
412 /* FIXME: there is a conflict, find
413 * the conflicting reservations and
414 * take a sensible action. Consider
415 * that in drp_ie there is the
416 * "neighbour" */
417 uwb_drp_handle_all_conflict_rsv(rc, drp_evt,
418 drp_ie, mas);
419 } else {
420 /* accept the extra reservation */
421 bitmap_copy(mv->companion_mas.bm, mas->bm,
422 UWB_NUM_MAS);
423 uwb_rsv_set_state(rsv,
424 UWB_RSV_STATE_T_EXPANDING_ACCEPTED);
425 }
426 } else {
427 if (status) {
428 uwb_rsv_set_state(rsv,
429 UWB_RSV_STATE_T_ACCEPTED);
430 }
431 }
432
371 } 433 }
372} 434}
373 435
374/* 436/*
375 * Based on the DRP IE, transition a target reservation to a new 437 * Based on the DRP IE, transition a target reservation to a new
376 * state. 438 * state.
377 */ 439 */
378static void uwb_drp_process_target(struct uwb_rc *rc, struct uwb_rsv *rsv, 440static void uwb_drp_process_target(struct uwb_rc *rc, struct uwb_rsv *rsv,
379 struct uwb_ie_drp *drp_ie, struct uwb_rc_evt_drp *drp_evt) 441 struct uwb_ie_drp *drp_ie, struct uwb_rc_evt_drp *drp_evt)
380{ 442{
381 struct device *dev = &rc->uwb_dev.dev; 443 struct device *dev = &rc->uwb_dev.dev;
382 struct uwb_rsv_move *mv = &rsv->mv; 444 struct uwb_rsv_move *mv = &rsv->mv;
383 int status; 445 int status;
384 enum uwb_drp_reason reason_code; 446 enum uwb_drp_reason reason_code;
385 struct uwb_mas_bm mas; 447 struct uwb_mas_bm mas;
386 448
387 status = uwb_ie_drp_status(drp_ie); 449 status = uwb_ie_drp_status(drp_ie);
388 reason_code = uwb_ie_drp_reason_code(drp_ie); 450 reason_code = uwb_ie_drp_reason_code(drp_ie);
389 uwb_drp_ie_to_bm(&mas, drp_ie); 451 uwb_drp_ie_to_bm(&mas, drp_ie);
390 452
391 switch (reason_code) { 453 switch (reason_code) {
392 case UWB_DRP_REASON_ACCEPTED: 454 case UWB_DRP_REASON_ACCEPTED:
393 455 uwb_drp_process_target_accepted(rc, rsv, drp_evt, drp_ie, &mas);
394 if (rsv->state == UWB_RSV_STATE_T_CONFLICT) {
395 uwb_rsv_set_state(rsv, UWB_RSV_STATE_T_CONFLICT);
396 break;
397 }
398
399 if (rsv->state == UWB_RSV_STATE_T_EXPANDING_ACCEPTED) {
400 /* drp_ie is companion */
401 if (!bitmap_equal(rsv->mas.bm, mas.bm, UWB_NUM_MAS))
402 /* stroke companion */
403 uwb_rsv_set_state(rsv, UWB_RSV_STATE_T_EXPANDING_ACCEPTED);
404 } else {
405 if (!bitmap_equal(rsv->mas.bm, mas.bm, UWB_NUM_MAS)) {
406 if (uwb_drp_avail_reserve_pending(rc, &mas) == -EBUSY) {
407 /* FIXME: there is a conflict, find
408 * the conflicting reservations and
409 * take a sensible action. Consider
410 * that in drp_ie there is the
411 * "neighbour" */
412 uwb_drp_handle_all_conflict_rsv(rc, drp_evt, drp_ie, &mas);
413 } else {
414 /* accept the extra reservation */
415 bitmap_copy(mv->companion_mas.bm, mas.bm, UWB_NUM_MAS);
416 uwb_rsv_set_state(rsv, UWB_RSV_STATE_T_EXPANDING_ACCEPTED);
417 }
418 } else {
419 if (status) {
420 uwb_rsv_set_state(rsv, UWB_RSV_STATE_T_ACCEPTED);
421 }
422 }
423
424 }
425 break; 456 break;
426 457
427 case UWB_DRP_REASON_MODIFIED: 458 case UWB_DRP_REASON_MODIFIED:
@@ -434,7 +465,8 @@ static void uwb_drp_process_target(struct uwb_rc *rc, struct uwb_rsv *rsv,
434 /* find if the owner wants to expand or reduce */ 465 /* find if the owner wants to expand or reduce */
435 if (bitmap_subset(mas.bm, rsv->mas.bm, UWB_NUM_MAS)) { 466 if (bitmap_subset(mas.bm, rsv->mas.bm, UWB_NUM_MAS)) {
436 /* owner is reducing */ 467 /* owner is reducing */
437 bitmap_andnot(mv->companion_mas.bm, rsv->mas.bm, mas.bm, UWB_NUM_MAS); 468 bitmap_andnot(mv->companion_mas.bm, rsv->mas.bm, mas.bm,
469 UWB_NUM_MAS);
438 uwb_drp_avail_release(rsv->rc, &mv->companion_mas); 470 uwb_drp_avail_release(rsv->rc, &mv->companion_mas);
439 } 471 }
440 472
@@ -447,6 +479,48 @@ static void uwb_drp_process_target(struct uwb_rc *rc, struct uwb_rsv *rsv,
447 } 479 }
448} 480}
449 481
482static void uwb_drp_process_owner_accepted(struct uwb_rsv *rsv,
483 struct uwb_mas_bm *mas)
484{
485 struct uwb_rsv_move *mv = &rsv->mv;
486
487 switch (rsv->state) {
488 case UWB_RSV_STATE_O_PENDING:
489 case UWB_RSV_STATE_O_INITIATED:
490 case UWB_RSV_STATE_O_ESTABLISHED:
491 uwb_rsv_set_state(rsv, UWB_RSV_STATE_O_ESTABLISHED);
492 break;
493 case UWB_RSV_STATE_O_MODIFIED:
494 if (bitmap_equal(mas->bm, rsv->mas.bm, UWB_NUM_MAS))
495 uwb_rsv_set_state(rsv, UWB_RSV_STATE_O_ESTABLISHED);
496 else
497 uwb_rsv_set_state(rsv, UWB_RSV_STATE_O_MODIFIED);
498 break;
499
500 case UWB_RSV_STATE_O_MOVE_REDUCING: /* shouldn' t be a problem */
501 if (bitmap_equal(mas->bm, rsv->mas.bm, UWB_NUM_MAS))
502 uwb_rsv_set_state(rsv, UWB_RSV_STATE_O_ESTABLISHED);
503 else
504 uwb_rsv_set_state(rsv, UWB_RSV_STATE_O_MOVE_REDUCING);
505 break;
506 case UWB_RSV_STATE_O_MOVE_EXPANDING:
507 if (bitmap_equal(mas->bm, mv->companion_mas.bm, UWB_NUM_MAS)) {
508 /* Companion reservation accepted */
509 uwb_rsv_set_state(rsv, UWB_RSV_STATE_O_MOVE_COMBINING);
510 } else {
511 uwb_rsv_set_state(rsv, UWB_RSV_STATE_O_MOVE_EXPANDING);
512 }
513 break;
514 case UWB_RSV_STATE_O_MOVE_COMBINING:
515 if (bitmap_equal(mas->bm, rsv->mas.bm, UWB_NUM_MAS))
516 uwb_rsv_set_state(rsv, UWB_RSV_STATE_O_MOVE_REDUCING);
517 else
518 uwb_rsv_set_state(rsv, UWB_RSV_STATE_O_MOVE_COMBINING);
519 break;
520 default:
521 break;
522 }
523}
450/* 524/*
451 * Based on the DRP IE, transition an owner reservation to a new 525 * Based on the DRP IE, transition an owner reservation to a new
452 * state. 526 * state.
@@ -456,7 +530,6 @@ static void uwb_drp_process_owner(struct uwb_rc *rc, struct uwb_rsv *rsv,
456 struct uwb_rc_evt_drp *drp_evt) 530 struct uwb_rc_evt_drp *drp_evt)
457{ 531{
458 struct device *dev = &rc->uwb_dev.dev; 532 struct device *dev = &rc->uwb_dev.dev;
459 struct uwb_rsv_move *mv = &rsv->mv;
460 int status; 533 int status;
461 enum uwb_drp_reason reason_code; 534 enum uwb_drp_reason reason_code;
462 struct uwb_mas_bm mas; 535 struct uwb_mas_bm mas;
@@ -468,44 +541,7 @@ static void uwb_drp_process_owner(struct uwb_rc *rc, struct uwb_rsv *rsv,
468 if (status) { 541 if (status) {
469 switch (reason_code) { 542 switch (reason_code) {
470 case UWB_DRP_REASON_ACCEPTED: 543 case UWB_DRP_REASON_ACCEPTED:
471 switch (rsv->state) { 544 uwb_drp_process_owner_accepted(rsv, &mas);
472 case UWB_RSV_STATE_O_PENDING:
473 case UWB_RSV_STATE_O_INITIATED:
474 case UWB_RSV_STATE_O_ESTABLISHED:
475 uwb_rsv_set_state(rsv, UWB_RSV_STATE_O_ESTABLISHED);
476 break;
477 case UWB_RSV_STATE_O_MODIFIED:
478 if (bitmap_equal(mas.bm, rsv->mas.bm, UWB_NUM_MAS)) {
479 uwb_rsv_set_state(rsv, UWB_RSV_STATE_O_ESTABLISHED);
480 } else {
481 uwb_rsv_set_state(rsv, UWB_RSV_STATE_O_MODIFIED);
482 }
483 break;
484
485 case UWB_RSV_STATE_O_MOVE_REDUCING: /* shouldn' t be a problem */
486 if (bitmap_equal(mas.bm, rsv->mas.bm, UWB_NUM_MAS)) {
487 uwb_rsv_set_state(rsv, UWB_RSV_STATE_O_ESTABLISHED);
488 } else {
489 uwb_rsv_set_state(rsv, UWB_RSV_STATE_O_MOVE_REDUCING);
490 }
491 break;
492 case UWB_RSV_STATE_O_MOVE_EXPANDING:
493 if (bitmap_equal(mas.bm, mv->companion_mas.bm, UWB_NUM_MAS)) {
494 /* Companion reservation accepted */
495 uwb_rsv_set_state(rsv, UWB_RSV_STATE_O_MOVE_COMBINING);
496 } else {
497 uwb_rsv_set_state(rsv, UWB_RSV_STATE_O_MOVE_EXPANDING);
498 }
499 break;
500 case UWB_RSV_STATE_O_MOVE_COMBINING:
501 if (bitmap_equal(mas.bm, rsv->mas.bm, UWB_NUM_MAS))
502 uwb_rsv_set_state(rsv, UWB_RSV_STATE_O_MOVE_REDUCING);
503 else
504 uwb_rsv_set_state(rsv, UWB_RSV_STATE_O_MOVE_COMBINING);
505 break;
506 default:
507 break;
508 }
509 break; 545 break;
510 default: 546 default:
511 dev_warn(dev, "ignoring invalid DRP IE state (%d/%d)\n", 547 dev_warn(dev, "ignoring invalid DRP IE state (%d/%d)\n",
@@ -545,9 +581,9 @@ static void uwb_cnflt_update_work(struct work_struct *work)
545 cnflt_update_work); 581 cnflt_update_work);
546 struct uwb_cnflt_alien *c; 582 struct uwb_cnflt_alien *c;
547 struct uwb_rc *rc = cnflt->rc; 583 struct uwb_rc *rc = cnflt->rc;
548 584
549 unsigned long delay_us = UWB_MAS_LENGTH_US * UWB_MAS_PER_ZONE; 585 unsigned long delay_us = UWB_MAS_LENGTH_US * UWB_MAS_PER_ZONE;
550 586
551 mutex_lock(&rc->rsvs_mutex); 587 mutex_lock(&rc->rsvs_mutex);
552 588
553 list_del(&cnflt->rc_node); 589 list_del(&cnflt->rc_node);
@@ -556,10 +592,12 @@ static void uwb_cnflt_update_work(struct work_struct *work)
556 bitmap_zero(rc->cnflt_alien_bitmap.bm, UWB_NUM_MAS); 592 bitmap_zero(rc->cnflt_alien_bitmap.bm, UWB_NUM_MAS);
557 593
558 list_for_each_entry(c, &rc->cnflt_alien_list, rc_node) { 594 list_for_each_entry(c, &rc->cnflt_alien_list, rc_node) {
559 bitmap_or(rc->cnflt_alien_bitmap.bm, rc->cnflt_alien_bitmap.bm, c->mas.bm, UWB_NUM_MAS); 595 bitmap_or(rc->cnflt_alien_bitmap.bm, rc->cnflt_alien_bitmap.bm,
596 c->mas.bm, UWB_NUM_MAS);
560 } 597 }
561 598
562 queue_delayed_work(rc->rsv_workq, &rc->rsv_alien_bp_work, usecs_to_jiffies(delay_us)); 599 queue_delayed_work(rc->rsv_workq, &rc->rsv_alien_bp_work,
600 usecs_to_jiffies(delay_us));
563 601
564 kfree(cnflt); 602 kfree(cnflt);
565 mutex_unlock(&rc->rsvs_mutex); 603 mutex_unlock(&rc->rsvs_mutex);
@@ -583,10 +621,10 @@ static void uwb_drp_handle_alien_drp(struct uwb_rc *rc, struct uwb_ie_drp *drp_i
583 struct uwb_cnflt_alien *cnflt; 621 struct uwb_cnflt_alien *cnflt;
584 char buf[72]; 622 char buf[72];
585 unsigned long delay_us = UWB_MAS_LENGTH_US * UWB_MAS_PER_ZONE; 623 unsigned long delay_us = UWB_MAS_LENGTH_US * UWB_MAS_PER_ZONE;
586 624
587 uwb_drp_ie_to_bm(&mas, drp_ie); 625 uwb_drp_ie_to_bm(&mas, drp_ie);
588 bitmap_scnprintf(buf, sizeof(buf), mas.bm, UWB_NUM_MAS); 626 bitmap_scnprintf(buf, sizeof(buf), mas.bm, UWB_NUM_MAS);
589 627
590 list_for_each_entry(cnflt, &rc->cnflt_alien_list, rc_node) { 628 list_for_each_entry(cnflt, &rc->cnflt_alien_list, rc_node) {
591 if (bitmap_equal(cnflt->mas.bm, mas.bm, UWB_NUM_MAS)) { 629 if (bitmap_equal(cnflt->mas.bm, mas.bm, UWB_NUM_MAS)) {
592 /* Existing alien BP reservation conflicting 630 /* Existing alien BP reservation conflicting
@@ -612,7 +650,7 @@ static void uwb_drp_handle_alien_drp(struct uwb_rc *rc, struct uwb_ie_drp *drp_i
612 650
613 cnflt->rc = rc; 651 cnflt->rc = rc;
614 INIT_WORK(&cnflt->cnflt_update_work, uwb_cnflt_update_work); 652 INIT_WORK(&cnflt->cnflt_update_work, uwb_cnflt_update_work);
615 653
616 bitmap_copy(cnflt->mas.bm, mas.bm, UWB_NUM_MAS); 654 bitmap_copy(cnflt->mas.bm, mas.bm, UWB_NUM_MAS);
617 655
618 list_add_tail(&cnflt->rc_node, &rc->cnflt_alien_list); 656 list_add_tail(&cnflt->rc_node, &rc->cnflt_alien_list);
@@ -621,17 +659,17 @@ static void uwb_drp_handle_alien_drp(struct uwb_rc *rc, struct uwb_ie_drp *drp_i
621 bitmap_or(rc->cnflt_alien_bitmap.bm, rc->cnflt_alien_bitmap.bm, mas.bm, UWB_NUM_MAS); 659 bitmap_or(rc->cnflt_alien_bitmap.bm, rc->cnflt_alien_bitmap.bm, mas.bm, UWB_NUM_MAS);
622 660
623 queue_delayed_work(rc->rsv_workq, &rc->rsv_alien_bp_work, usecs_to_jiffies(delay_us)); 661 queue_delayed_work(rc->rsv_workq, &rc->rsv_alien_bp_work, usecs_to_jiffies(delay_us));
624 662
625 /* start the timer */ 663 /* start the timer */
626 uwb_cnflt_alien_stroke_timer(cnflt); 664 uwb_cnflt_alien_stroke_timer(cnflt);
627} 665}
628 666
629static void uwb_drp_process_not_involved(struct uwb_rc *rc, 667static void uwb_drp_process_not_involved(struct uwb_rc *rc,
630 struct uwb_rc_evt_drp *drp_evt, 668 struct uwb_rc_evt_drp *drp_evt,
631 struct uwb_ie_drp *drp_ie) 669 struct uwb_ie_drp *drp_ie)
632{ 670{
633 struct uwb_mas_bm mas; 671 struct uwb_mas_bm mas;
634 672
635 uwb_drp_ie_to_bm(&mas, drp_ie); 673 uwb_drp_ie_to_bm(&mas, drp_ie);
636 uwb_drp_handle_all_conflict_rsv(rc, drp_evt, drp_ie, &mas); 674 uwb_drp_handle_all_conflict_rsv(rc, drp_evt, drp_ie, &mas);
637} 675}
@@ -651,7 +689,7 @@ static void uwb_drp_process_involved(struct uwb_rc *rc, struct uwb_dev *src,
651 */ 689 */
652 return; 690 return;
653 } 691 }
654 692
655 /* 693 /*
656 * Do nothing with DRP IEs for reservations that have been 694 * Do nothing with DRP IEs for reservations that have been
657 * terminated. 695 * terminated.
@@ -660,12 +698,12 @@ static void uwb_drp_process_involved(struct uwb_rc *rc, struct uwb_dev *src,
660 uwb_rsv_set_state(rsv, UWB_RSV_STATE_NONE); 698 uwb_rsv_set_state(rsv, UWB_RSV_STATE_NONE);
661 return; 699 return;
662 } 700 }
663 701
664 if (uwb_ie_drp_owner(drp_ie)) 702 if (uwb_ie_drp_owner(drp_ie))
665 uwb_drp_process_target(rc, rsv, drp_ie, drp_evt); 703 uwb_drp_process_target(rc, rsv, drp_ie, drp_evt);
666 else 704 else
667 uwb_drp_process_owner(rc, rsv, src, drp_ie, drp_evt); 705 uwb_drp_process_owner(rc, rsv, src, drp_ie, drp_evt);
668 706
669} 707}
670 708
671 709