1 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ 2 /* 3 * Copyright (C) 2024-2025 Intel Corporation 4 */ 5 #ifndef __iwl_mld_hcmd_h__ 6 #define __iwl_mld_hcmd_h__ 7 8 static inline int iwl_mld_send_cmd(struct iwl_mld *mld, struct iwl_host_cmd *cmd) 9 { 10 /* No commands, including the d3 related commands, should be sent 11 * after entering d3 12 */ 13 #ifdef CONFIG_PM_SLEEP 14 if (WARN_ON(mld->fw_status.in_d3)) 15 return -EIO; 16 #endif 17 18 if (!(cmd->flags & CMD_ASYNC)) 19 lockdep_assert_wiphy(mld->wiphy); 20 21 /* Devices that need to shutdown immediately on rfkill are not 22 * supported, so we can send all the cmds in rfkill 23 */ 24 cmd->flags |= CMD_SEND_IN_RFKILL; 25 26 return iwl_trans_send_cmd(mld->trans, cmd); 27 } 28 29 static inline int 30 __iwl_mld_send_cmd_with_flags_pdu(struct iwl_mld *mld, u32 id, 31 u32 flags, const void *data, u16 len) 32 { 33 struct iwl_host_cmd cmd = { 34 .id = id, 35 .len = { data ? len : 0, }, 36 .data = { data, }, 37 .flags = flags, 38 }; 39 40 return iwl_mld_send_cmd(mld, &cmd); 41 } 42 43 #define _iwl_mld_send_cmd_with_flags_pdu(mld, id, flags, data, len, \ 44 ignored...) \ 45 __iwl_mld_send_cmd_with_flags_pdu(mld, id, flags, data, len) 46 #define iwl_mld_send_cmd_with_flags_pdu(mld, id, flags, data, len...) \ 47 _iwl_mld_send_cmd_with_flags_pdu(mld, id, flags, data, ##len, \ 48 sizeof(*(data))) 49 50 #define iwl_mld_send_cmd_pdu(mld, id, ...) \ 51 iwl_mld_send_cmd_with_flags_pdu(mld, id, 0, __VA_ARGS__) 52 53 #define iwl_mld_send_cmd_empty(mld, id) \ 54 iwl_mld_send_cmd_with_flags_pdu(mld, id, 0, NULL, 0) 55 56 #endif /* __iwl_mld_hcmd_h__ */ 57