aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/libertas/mesh.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/libertas/mesh.c')
-rw-r--r--drivers/net/wireless/libertas/mesh.c182
1 files changed, 150 insertions, 32 deletions
diff --git a/drivers/net/wireless/libertas/mesh.c b/drivers/net/wireless/libertas/mesh.c
index bc5bc1384c35..35ee574f588f 100644
--- a/drivers/net/wireless/libertas/mesh.c
+++ b/drivers/net/wireless/libertas/mesh.c
@@ -455,44 +455,162 @@ void lbs_mesh_set_txpd(struct lbs_private *priv,
455 * Mesh command handling 455 * Mesh command handling
456 */ 456 */
457 457
458int lbs_cmd_bt_access(struct cmd_ds_command *cmd, 458/**
459 u16 cmd_action, void *pdata_buf) 459 * @brief Add or delete Mesh Blinding Table entries
460 *
461 * @param priv A pointer to struct lbs_private structure
462 * @param add TRUE to add the entry, FALSE to delete it
463 * @param addr1 Destination address to blind or unblind
464 *
465 * @return 0 on success, error on failure
466 */
467int lbs_mesh_bt_add_del(struct lbs_private *priv, bool add, u8 *addr1)
460{ 468{
461 struct cmd_ds_bt_access *bt_access = &cmd->params.bt; 469 struct cmd_ds_bt_access cmd;
462 lbs_deb_enter_args(LBS_DEB_CMD, "action %d", cmd_action); 470 int ret = 0;
463 471
464 cmd->command = cpu_to_le16(CMD_BT_ACCESS); 472 lbs_deb_enter(LBS_DEB_CMD);
465 cmd->size = cpu_to_le16(sizeof(struct cmd_ds_bt_access) + 473
466 sizeof(struct cmd_header)); 474 BUG_ON(addr1 == NULL);
467 cmd->result = 0;
468 bt_access->action = cpu_to_le16(cmd_action);
469 475
470 switch (cmd_action) { 476 memset(&cmd, 0, sizeof(cmd));
471 case CMD_ACT_BT_ACCESS_ADD: 477 cmd.hdr.size = cpu_to_le16(sizeof(cmd));
472 memcpy(bt_access->addr1, pdata_buf, 2 * ETH_ALEN); 478 memcpy(cmd.addr1, addr1, ETH_ALEN);
479 if (add) {
480 cmd.action = cpu_to_le16(CMD_ACT_BT_ACCESS_ADD);
473 lbs_deb_hex(LBS_DEB_MESH, "BT_ADD: blinded MAC addr", 481 lbs_deb_hex(LBS_DEB_MESH, "BT_ADD: blinded MAC addr",
474 bt_access->addr1, 6); 482 addr1, ETH_ALEN);
475 break; 483 } else {
476 case CMD_ACT_BT_ACCESS_DEL: 484 cmd.action = cpu_to_le16(CMD_ACT_BT_ACCESS_DEL);
477 memcpy(bt_access->addr1, pdata_buf, 1 * ETH_ALEN);
478 lbs_deb_hex(LBS_DEB_MESH, "BT_DEL: blinded MAC addr", 485 lbs_deb_hex(LBS_DEB_MESH, "BT_DEL: blinded MAC addr",
479 bt_access->addr1, 6); 486 addr1, ETH_ALEN);
480 break;
481 case CMD_ACT_BT_ACCESS_LIST:
482 bt_access->id = cpu_to_le32(*(u32 *) pdata_buf);
483 break;
484 case CMD_ACT_BT_ACCESS_RESET:
485 break;
486 case CMD_ACT_BT_ACCESS_SET_INVERT:
487 bt_access->id = cpu_to_le32(*(u32 *) pdata_buf);
488 break;
489 case CMD_ACT_BT_ACCESS_GET_INVERT:
490 break;
491 default:
492 break;
493 } 487 }
494 lbs_deb_leave(LBS_DEB_CMD); 488
495 return 0; 489 ret = lbs_cmd_with_response(priv, CMD_BT_ACCESS, &cmd);
490
491 lbs_deb_leave_args(LBS_DEB_CMD, "ret %d", ret);
492 return ret;
493}
494
495/**
496 * @brief Reset/clear the mesh blinding table
497 *
498 * @param priv A pointer to struct lbs_private structure
499 *
500 * @return 0 on success, error on failure
501 */
502int lbs_mesh_bt_reset(struct lbs_private *priv)
503{
504 struct cmd_ds_bt_access cmd;
505 int ret = 0;
506
507 lbs_deb_enter(LBS_DEB_CMD);
508
509 memset(&cmd, 0, sizeof(cmd));
510 cmd.hdr.size = cpu_to_le16(sizeof(cmd));
511 cmd.action = cpu_to_le16(CMD_ACT_BT_ACCESS_RESET);
512
513 ret = lbs_cmd_with_response(priv, CMD_BT_ACCESS, &cmd);
514
515 lbs_deb_leave_args(LBS_DEB_CMD, "ret %d", ret);
516 return ret;
517}
518
519/**
520 * @brief Gets the inverted status of the mesh blinding table
521 *
522 * Normally the firmware "blinds" or ignores traffic from mesh nodes in the
523 * table, but an inverted table allows *only* traffic from nodes listed in
524 * the table.
525 *
526 * @param priv A pointer to struct lbs_private structure
527 * @param invert On success, TRUE if the blinding table is inverted,
528 * FALSE if it is not inverted
529 *
530 * @return 0 on success, error on failure
531 */
532int lbs_mesh_bt_get_inverted(struct lbs_private *priv, bool *inverted)
533{
534 struct cmd_ds_bt_access cmd;
535 int ret = 0;
536
537 lbs_deb_enter(LBS_DEB_CMD);
538
539 BUG_ON(inverted == NULL);
540
541 memset(&cmd, 0, sizeof(cmd));
542 cmd.hdr.size = cpu_to_le16(sizeof(cmd));
543 cmd.action = cpu_to_le16(CMD_ACT_BT_ACCESS_GET_INVERT);
544
545 ret = lbs_cmd_with_response(priv, CMD_BT_ACCESS, &cmd);
546 if (ret == 0)
547 *inverted = !!cmd.id;
548
549 lbs_deb_leave_args(LBS_DEB_CMD, "ret %d", ret);
550 return ret;
551}
552
553/**
554 * @brief Sets the inverted status of the mesh blinding table
555 *
556 * Normally the firmware "blinds" or ignores traffic from mesh nodes in the
557 * table, but an inverted table allows *only* traffic from nodes listed in
558 * the table.
559 *
560 * @param priv A pointer to struct lbs_private structure
561 * @param invert TRUE to invert the blinding table (only traffic from
562 * listed nodes allowed), FALSE to return it
563 * to normal state (listed nodes ignored)
564 *
565 * @return 0 on success, error on failure
566 */
567int lbs_mesh_bt_set_inverted(struct lbs_private *priv, bool inverted)
568{
569 struct cmd_ds_bt_access cmd;
570 int ret = 0;
571
572 lbs_deb_enter(LBS_DEB_CMD);
573
574 memset(&cmd, 0, sizeof(cmd));
575 cmd.hdr.size = cpu_to_le16(sizeof(cmd));
576 cmd.action = cpu_to_le16(CMD_ACT_BT_ACCESS_SET_INVERT);
577 cmd.id = !!inverted;
578
579 ret = lbs_cmd_with_response(priv, CMD_BT_ACCESS, &cmd);
580
581 lbs_deb_leave_args(LBS_DEB_CMD, "ret %d", ret);
582 return ret;
583}
584
585/**
586 * @brief List an entry in the mesh blinding table
587 *
588 * @param priv A pointer to struct lbs_private structure
589 * @param id The ID of the entry to list
590 * @param addr1 MAC address associated with the table entry
591 *
592 * @return 0 on success, error on failure
593 */
594int lbs_mesh_bt_get_entry(struct lbs_private *priv, u32 id, u8 *addr1)
595{
596 struct cmd_ds_bt_access cmd;
597 int ret = 0;
598
599 lbs_deb_enter(LBS_DEB_CMD);
600
601 BUG_ON(addr1 == NULL);
602
603 memset(&cmd, 0, sizeof(cmd));
604 cmd.hdr.size = cpu_to_le16(sizeof(cmd));
605 cmd.action = cpu_to_le16(CMD_ACT_BT_ACCESS_SET_INVERT);
606 cmd.id = cpu_to_le32(id);
607
608 ret = lbs_cmd_with_response(priv, CMD_BT_ACCESS, &cmd);
609 if (ret == 0)
610 memcpy(addr1, cmd.addr1, sizeof(cmd.addr1));
611
612 lbs_deb_leave_args(LBS_DEB_CMD, "ret %d", ret);
613 return ret;
496} 614}
497 615
498int lbs_cmd_fwt_access(struct cmd_ds_command *cmd, 616int lbs_cmd_fwt_access(struct cmd_ds_command *cmd,