Path: blob/main/sys/contrib/dev/iwlwifi/fw/dhc-utils.h
48287 views
/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */1/*2* Copyright (C) 2021, 2025 Intel Corporation3*/4#ifndef __iwl_fw_dhc_utils_h__5#define __iwl_fw_dhc_utils_h__67#include <linux/types.h>8#include "fw/img.h"9#include "api/commands.h"10#include "api/dhc.h"1112/**13* iwl_dhc_resp_status - return status of DHC response14* @fw: firwmware image information15* @pkt: response packet, must not be %NULL16*17* Returns: the status value of the DHC command or (u32)-1 if the18* response was too short.19*/20static inline u32 iwl_dhc_resp_status(const struct iwl_fw *fw,21struct iwl_rx_packet *pkt)22{23if (iwl_fw_lookup_notif_ver(fw, IWL_ALWAYS_LONG_GROUP,24DEBUG_HOST_COMMAND, 1) >= 2) {25struct iwl_dhc_cmd_resp *resp = (void *)pkt->data;2627if (iwl_rx_packet_payload_len(pkt) < sizeof(*resp))28return (u32)-1;2930return le32_to_cpu(resp->status);31} else {32struct iwl_dhc_cmd_resp_v1 *resp = (void *)pkt->data;3334if (iwl_rx_packet_payload_len(pkt) < sizeof(*resp))35return (u32)-1;3637return le32_to_cpu(resp->status);38}39}4041/**42* iwl_dhc_resp_data - return data pointer of DHC response43* @fw: firwmware image information44* @pkt: response packet, must not be %NULL45* @len: where to store the length46*47* Returns: The data pointer, or an ERR_PTR() if the data was48* not valid (too short).49*/50static inline void *iwl_dhc_resp_data(const struct iwl_fw *fw,51struct iwl_rx_packet *pkt,52unsigned int *len)53{54if (iwl_fw_lookup_notif_ver(fw, IWL_ALWAYS_LONG_GROUP,55DEBUG_HOST_COMMAND, 1) >= 2) {56struct iwl_dhc_cmd_resp *resp = (void *)pkt->data;5758if (iwl_rx_packet_payload_len(pkt) < sizeof(*resp))59return ERR_PTR(-EINVAL);6061*len = iwl_rx_packet_payload_len(pkt) - sizeof(*resp);62return (void *)&resp->data;63} else {64struct iwl_dhc_cmd_resp_v1 *resp = (void *)pkt->data;6566if (iwl_rx_packet_payload_len(pkt) < sizeof(*resp))67return ERR_PTR(-EINVAL);6869*len = iwl_rx_packet_payload_len(pkt) - sizeof(*resp);70return (void *)&resp->data;71}72}7374#endif /* __iwl_fw_dhc_utils_h__ */757677