xref: /linux/drivers/net/wireless/intel/iwlwifi/iwl-utils.h (revision 0ad9617c78acbc71373fb341a6f75d4012b01d69)
17ceae9b7SDaniel Gabay /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
27ceae9b7SDaniel Gabay /*
37ceae9b7SDaniel Gabay  * Copyright (C) 2024 Intel Corporation
47ceae9b7SDaniel Gabay  */
57ceae9b7SDaniel Gabay #ifndef __iwl_utils_h__
67ceae9b7SDaniel Gabay #define __iwl_utils_h__
77ceae9b7SDaniel Gabay 
8*59704425SMiri Korenblit #include <net/cfg80211.h>
9*59704425SMiri Korenblit 
107ceae9b7SDaniel Gabay #ifdef CONFIG_INET
117ceae9b7SDaniel Gabay /**
127ceae9b7SDaniel Gabay  * iwl_tx_tso_segment - Segments a TSO packet into subframes for A-MSDU.
137ceae9b7SDaniel Gabay  * @skb: buffer to segment.
147ceae9b7SDaniel Gabay  * @num_subframes: number of subframes to create.
157ceae9b7SDaniel Gabay  * @netdev_flags: netdev feature flags.
167ceae9b7SDaniel Gabay  * @mpdus_skbs: list to hold the segmented subframes.
177ceae9b7SDaniel Gabay  *
187ceae9b7SDaniel Gabay  * This function segments a large TCP packet into subframes.
197ceae9b7SDaniel Gabay  * subframes are added to the mpdus_skbs list
207ceae9b7SDaniel Gabay  *
217ceae9b7SDaniel Gabay  * Returns: 0 on success and negative value on failure.
227ceae9b7SDaniel Gabay  */
237ceae9b7SDaniel Gabay int iwl_tx_tso_segment(struct sk_buff *skb, unsigned int num_subframes,
247ceae9b7SDaniel Gabay 		       netdev_features_t netdev_flags,
257ceae9b7SDaniel Gabay 		       struct sk_buff_head *mpdus_skbs);
267ceae9b7SDaniel Gabay #else
277ceae9b7SDaniel Gabay static inline
287ceae9b7SDaniel Gabay int iwl_tx_tso_segment(struct sk_buff *skb, unsigned int num_subframes,
297ceae9b7SDaniel Gabay 		       netdev_features_t netdev_flags,
307ceae9b7SDaniel Gabay 		       struct sk_buff_head *mpdus_skbs)
317ceae9b7SDaniel Gabay {
327ceae9b7SDaniel Gabay 	WARN_ON(1);
337ceae9b7SDaniel Gabay 
347ceae9b7SDaniel Gabay 	return -1;
357ceae9b7SDaniel Gabay }
367ceae9b7SDaniel Gabay #endif /* CONFIG_INET */
377ceae9b7SDaniel Gabay 
38*59704425SMiri Korenblit static inline
39*59704425SMiri Korenblit u32 iwl_find_ie_offset(u8 *beacon, u8 eid, u32 frame_size)
40*59704425SMiri Korenblit {
41*59704425SMiri Korenblit 	struct ieee80211_mgmt *mgmt = (void *)beacon;
42*59704425SMiri Korenblit 	const u8 *ie;
43*59704425SMiri Korenblit 
44*59704425SMiri Korenblit 	if (WARN_ON_ONCE(frame_size <= (mgmt->u.beacon.variable - beacon)))
45*59704425SMiri Korenblit 		return 0;
46*59704425SMiri Korenblit 
47*59704425SMiri Korenblit 	frame_size -= mgmt->u.beacon.variable - beacon;
48*59704425SMiri Korenblit 
49*59704425SMiri Korenblit 	ie = cfg80211_find_ie(eid, mgmt->u.beacon.variable, frame_size);
50*59704425SMiri Korenblit 	if (!ie)
51*59704425SMiri Korenblit 		return 0;
52*59704425SMiri Korenblit 
53*59704425SMiri Korenblit 	return ie - beacon;
54*59704425SMiri Korenblit }
55*59704425SMiri Korenblit 
567ceae9b7SDaniel Gabay #endif /* __iwl_utils_h__ */
57