1 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ 2 /* 3 * Copyright (C) 2024-2026 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 ({ \ 46 BUILD_BUG_ON(__builtin_constant_p(len) && \ 47 (u16)(len) > IWL_MAX_CMD_PAYLOAD_SIZE); \ 48 __iwl_mld_send_cmd_with_flags_pdu(mld, id, flags, \ 49 data, len); \ 50 }) 51 #define iwl_mld_send_cmd_with_flags_pdu(mld, id, flags, data, len...) \ 52 _iwl_mld_send_cmd_with_flags_pdu(mld, id, flags, data, ##len, \ 53 sizeof(*(data))) 54 55 #define iwl_mld_send_cmd_pdu(mld, id, ...) \ 56 iwl_mld_send_cmd_with_flags_pdu(mld, id, 0, __VA_ARGS__) 57 58 #define iwl_mld_send_cmd_empty(mld, id) \ 59 iwl_mld_send_cmd_with_flags_pdu(mld, id, 0, NULL, 0) 60 61 #endif /* __iwl_mld_hcmd_h__ */ 62