Linux Audio

Check our new training course

Loading...
v6.13.7
  1/* SPDX-License-Identifier: GPL-2.0-only */
  2/*
  3 * Copyright 2016 Broadcom
  4 */
  5
  6#ifndef _UTIL_H
  7#define _UTIL_H
  8
  9#include <linux/kernel.h>
 10#include <linux/delay.h>
 11
 12#include "spu.h"
 13
 14extern int flow_debug_logging;
 15extern int packet_debug_logging;
 16extern int debug_logging_sleep;
 17
 18#ifdef DEBUG
 19#define flow_log(...)	                \
 20	do {	                              \
 21		if (flow_debug_logging) {	        \
 22			printk(__VA_ARGS__);	          \
 23			if (debug_logging_sleep)	      \
 24				msleep(debug_logging_sleep);	\
 25		}	                                \
 26	} while (0)
 27#define flow_dump(msg, var, var_len)	   \
 28	do {	                                 \
 29		if (flow_debug_logging) {	           \
 30			print_hex_dump(KERN_ALERT, msg, DUMP_PREFIX_NONE,  \
 31					16, 1, var, var_len, false); \
 32				if (debug_logging_sleep)	       \
 33					msleep(debug_logging_sleep);   \
 34		}                                    \
 35	} while (0)
 36
 37#define packet_log(...)               \
 38	do {                                \
 39		if (packet_debug_logging) {       \
 40			printk(__VA_ARGS__);            \
 41			if (debug_logging_sleep)        \
 42				msleep(debug_logging_sleep);  \
 43		}                                 \
 44	} while (0)
 45#define packet_dump(msg, var, var_len)   \
 46	do {                                   \
 47		if (packet_debug_logging) {          \
 48			print_hex_dump(KERN_ALERT, msg, DUMP_PREFIX_NONE,  \
 49					16, 1, var, var_len, false); \
 50			if (debug_logging_sleep)           \
 51				msleep(debug_logging_sleep);     \
 52		}                                    \
 53	} while (0)
 54
 55void __dump_sg(struct scatterlist *sg, unsigned int skip, unsigned int len);
 56
 57#define dump_sg(sg, skip, len)     __dump_sg(sg, skip, len)
 58
 59#else /* !DEBUG_ON */
 60
 61static inline void flow_log(const char *format, ...)
 62{
 63}
 
 64
 65static inline void flow_dump(const char *msg, const void *var, size_t var_len)
 66{
 67}
 68
 69static inline void packet_log(const char *format, ...)
 70{
 71}
 72
 73static inline void packet_dump(const char *msg, const void *var, size_t var_len)
 74{
 75}
 76
 77static inline void dump_sg(struct scatterlist *sg, unsigned int skip,
 78			   unsigned int len)
 79{
 80}
 81
 82#endif /* DEBUG_ON */
 83
 84int spu_sg_at_offset(struct scatterlist *sg, unsigned int skip,
 85		     struct scatterlist **sge, unsigned int *sge_offset);
 86
 87/* Copy sg data, from skip, length len, to dest */
 88void sg_copy_part_to_buf(struct scatterlist *src, u8 *dest,
 89			 unsigned int len, unsigned int skip);
 90/* Copy src into scatterlist from offset, length len */
 91void sg_copy_part_from_buf(struct scatterlist *dest, u8 *src,
 92			   unsigned int len, unsigned int skip);
 93
 94int spu_sg_count(struct scatterlist *sg_list, unsigned int skip, int nbytes);
 95u32 spu_msg_sg_add(struct scatterlist **to_sg,
 96		   struct scatterlist **from_sg, u32 *skip,
 97		   u8 from_nents, u32 tot_len);
 98
 99void add_to_ctr(u8 *ctr_pos, unsigned int increment);
100
101/* produce a message digest from data of length n bytes */
102int do_shash(unsigned char *name, unsigned char *result,
103	     const u8 *data1, unsigned int data1_len,
104	     const u8 *data2, unsigned int data2_len,
105	     const u8 *key, unsigned int key_len);
106
107char *spu_alg_name(enum spu_cipher_alg alg, enum spu_cipher_mode mode);
108
109void spu_setup_debugfs(void);
110void spu_free_debugfs(void);
111void format_value_ccm(unsigned int val, u8 *buf, u8 len);
112
113#endif
v5.4
 1/* SPDX-License-Identifier: GPL-2.0-only */
 2/*
 3 * Copyright 2016 Broadcom
 4 */
 5
 6#ifndef _UTIL_H
 7#define _UTIL_H
 8
 9#include <linux/kernel.h>
10#include <linux/delay.h>
11
12#include "spu.h"
13
14extern int flow_debug_logging;
15extern int packet_debug_logging;
16extern int debug_logging_sleep;
17
18#ifdef DEBUG
19#define flow_log(...)	                \
20	do {	                              \
21		if (flow_debug_logging) {	        \
22			printk(__VA_ARGS__);	          \
23			if (debug_logging_sleep)	      \
24				msleep(debug_logging_sleep);	\
25		}	                                \
26	} while (0)
27#define flow_dump(msg, var, var_len)	   \
28	do {	                                 \
29		if (flow_debug_logging) {	           \
30			print_hex_dump(KERN_ALERT, msg, DUMP_PREFIX_NONE,  \
31					16, 1, var, var_len, false); \
32				if (debug_logging_sleep)	       \
33					msleep(debug_logging_sleep);   \
34		}                                    \
35	} while (0)
36
37#define packet_log(...)               \
38	do {                                \
39		if (packet_debug_logging) {       \
40			printk(__VA_ARGS__);            \
41			if (debug_logging_sleep)        \
42				msleep(debug_logging_sleep);  \
43		}                                 \
44	} while (0)
45#define packet_dump(msg, var, var_len)   \
46	do {                                   \
47		if (packet_debug_logging) {          \
48			print_hex_dump(KERN_ALERT, msg, DUMP_PREFIX_NONE,  \
49					16, 1, var, var_len, false); \
50			if (debug_logging_sleep)           \
51				msleep(debug_logging_sleep);     \
52		}                                    \
53	} while (0)
54
55void __dump_sg(struct scatterlist *sg, unsigned int skip, unsigned int len);
56
57#define dump_sg(sg, skip, len)     __dump_sg(sg, skip, len)
58
59#else /* !DEBUG_ON */
60
61#define flow_log(...) do {} while (0)
62#define flow_dump(msg, var, var_len) do {} while (0)
63#define packet_log(...) do {} while (0)
64#define packet_dump(msg, var, var_len) do {} while (0)
65
66#define dump_sg(sg, skip, len) do {} while (0)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
67
68#endif /* DEBUG_ON */
69
70int spu_sg_at_offset(struct scatterlist *sg, unsigned int skip,
71		     struct scatterlist **sge, unsigned int *sge_offset);
72
73/* Copy sg data, from skip, length len, to dest */
74void sg_copy_part_to_buf(struct scatterlist *src, u8 *dest,
75			 unsigned int len, unsigned int skip);
76/* Copy src into scatterlist from offset, length len */
77void sg_copy_part_from_buf(struct scatterlist *dest, u8 *src,
78			   unsigned int len, unsigned int skip);
79
80int spu_sg_count(struct scatterlist *sg_list, unsigned int skip, int nbytes);
81u32 spu_msg_sg_add(struct scatterlist **to_sg,
82		   struct scatterlist **from_sg, u32 *skip,
83		   u8 from_nents, u32 tot_len);
84
85void add_to_ctr(u8 *ctr_pos, unsigned int increment);
86
87/* produce a message digest from data of length n bytes */
88int do_shash(unsigned char *name, unsigned char *result,
89	     const u8 *data1, unsigned int data1_len,
90	     const u8 *data2, unsigned int data2_len,
91	     const u8 *key, unsigned int key_len);
92
93char *spu_alg_name(enum spu_cipher_alg alg, enum spu_cipher_mode mode);
94
95void spu_setup_debugfs(void);
96void spu_free_debugfs(void);
97void format_value_ccm(unsigned int val, u8 *buf, u8 len);
98
99#endif