1  /*
2   * Copyright (c) 2014-2017 The Linux Foundation. All rights reserved.
3   * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
4   *
5   * Permission to use, copy, modify, and/or distribute this software for
6   * any purpose with or without fee is hereby granted, provided that the
7   * above copyright notice and this permission notice appear in all
8   * copies.
9   *
10   * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
11   * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
12   * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
13   * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
14   * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
15   * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
16   * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17   * PERFORMANCE OF THIS SOFTWARE.
18   */
19  
20  /**
21   * DOC: i_qdf_net_types
22   * This file provides OS dependent net types API's.
23   */
24  
25  #ifndef _I_QDF_NET_TYPES_H
26  #define _I_QDF_NET_TYPES_H
27  
28  #include <qdf_types.h>          /* uint8_t, etc. */
29  #include <asm/checksum.h>
30  #include <net/ip6_checksum.h>
31  #include <net/tcp.h>
32  
33  typedef struct in6_addr __in6_addr_t;
34  typedef __wsum __wsum_t;
35  
__qdf_csum_ipv6(const struct in6_addr * saddr,const struct in6_addr * daddr,__u32 len,unsigned short proto,__wsum sum)36  static inline  int32_t __qdf_csum_ipv6(const struct in6_addr *saddr,
37  				       const struct in6_addr *daddr,
38  				       __u32 len, unsigned short proto,
39  				       __wsum sum)
40  {
41  	return csum_ipv6_magic((struct in6_addr *)saddr,
42  			       (struct in6_addr *)daddr, len, proto, sum);
43  }
44  
__qdf_netdev_get_devname(qdf_netdev_t dev)45  static inline char *__qdf_netdev_get_devname(qdf_netdev_t dev)
46  {
47  	return dev->name;
48  }
49  
50  static inline
__qdf_csum_tcpudp_magic(uint32_t ip_saddr,uint32_t ip_daddr,uint16_t adj_ip_len,uint8_t ip_proto,uint32_t sum)51  __sum16 __qdf_csum_tcpudp_magic(uint32_t ip_saddr, uint32_t ip_daddr,
52  				uint16_t adj_ip_len, uint8_t ip_proto,
53  				uint32_t sum)
54  {
55  	return csum_tcpudp_magic(ip_saddr, ip_daddr,
56  				 adj_ip_len, ip_proto, sum);
57  }
58  
59  static inline
__qdf_ip_fast_csum(void * ip_hdr,uint8_t ip_hl)60  uint16_t __qdf_ip_fast_csum(void *ip_hdr, uint8_t ip_hl)
61  {
62  	return ip_fast_csum((struct iphdr *)ip_hdr, ip_hl);
63  }
64  
65  #define __QDF_TCPHDR_FIN TCPHDR_FIN
66  #define __QDF_TCPHDR_SYN TCPHDR_SYN
67  #define __QDF_TCPHDR_RST TCPHDR_RST
68  #define __QDF_TCPHDR_PSH TCPHDR_PSH
69  #define __QDF_TCPHDR_ACK TCPHDR_ACK
70  #define __QDF_TCPHDR_URG TCPHDR_URG
71  #define __QDF_TCPHDR_ECE TCPHDR_ECE
72  #define __QDF_TCPHDR_CWR TCPHDR_CWR
73  #endif /* _I_QDF_NET_TYPES_H */
74