blob: 0a5a784fe574d43d854a72a87a08554f6d4433a3 [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
2 * Copyright (c) 2012-2015 The Linux Foundation. All rights reserved.
3 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27
28#ifndef _PKTLOG_AC_H_
29#define _PKTLOG_AC_H_
30#ifndef REMOVE_PKT_LOG
31
32#include "ol_if_athvar.h"
33#include <pktlog_ac_api.h>
34#include <pktlog_ac_fmt.h>
35#include "osdep.h"
36#include <wmi_unified.h>
37#include <wmi_unified_api.h>
38#include <wdi_event_api.h>
39#include "hif.h"
40
41#define NO_REG_FUNCS 4
42
43/* Locking interface for pktlog */
44#define PKTLOG_LOCK_INIT(_pl_info) spin_lock_init(&(_pl_info)->log_lock)
45#define PKTLOG_LOCK_DESTROY(_pl_info)
46#define PKTLOG_LOCK(_pl_info) spin_lock(&(_pl_info)->log_lock)
47#define PKTLOG_UNLOCK(_pl_info) spin_unlock(&(_pl_info)->log_lock)
48
49#define PKTLOG_MODE_SYSTEM 1
50#define PKTLOG_MODE_ADAPTER 2
51
52/*
53 * The proc entry starts with magic number and version field which will be
54 * used by post processing scripts. These fields are not needed by applications
55 * that do not use these scripts. This is skipped using the offset value.
56 */
57#define PKTLOG_READ_OFFSET 8
58
59/* Opaque softc */
60struct ol_ath_generic_softc_t;
61typedef struct ol_ath_generic_softc_t *ol_ath_generic_softc_handle;
62extern void pktlog_disable_adapter_logging(struct ol_softc *scn);
63extern int pktlog_alloc_buf(struct ol_softc *scn);
64extern void pktlog_release_buf(struct ol_softc *scn);
65
66ssize_t pktlog_read_proc_entry(char *buf, size_t nbytes, loff_t *ppos,
67 struct ath_pktlog_info *pl_info, bool *read_complete);
68int pktlog_send_per_pkt_stats_to_user(void);
69
70struct ol_pl_arch_dep_funcs {
71 void (*pktlog_init)(struct ol_softc *scn);
72 int (*pktlog_enable)(struct ol_softc *scn, int32_t log_state);
73 int (*pktlog_setsize)(struct ol_softc *scn, int32_t log_state);
74 int (*pktlog_disable)(struct ol_softc *scn);
75};
76
77struct ol_pl_os_dep_funcs {
78 int (*pktlog_attach)(struct ol_softc *scn);
79 void (*pktlog_detach)(struct ol_softc *scn);
80};
81
82struct ath_pktlog_wmi_params {
83 WMI_PKTLOG_EVENT pktlog_event;
84 WMI_CMD_ID cmd_id;
85};
86
87extern struct ol_pl_arch_dep_funcs ol_pl_funcs;
88extern struct ol_pl_os_dep_funcs *g_ol_pl_os_dep_funcs;
89
90/* Pktlog handler to save the state of the pktlogs */
91struct ol_pktlog_dev_t {
92 struct ol_pl_arch_dep_funcs *pl_funcs;
93 struct ath_pktlog_info *pl_info;
94 ol_ath_generic_softc_handle scn;
95 char *name;
96 bool tgt_pktlog_enabled;
97 osdev_t sc_osdev;
98};
99
100#define PKTLOG_SYSCTL_SIZE 14
101
102/*
103 * Linux specific pktlog state information
104 */
105struct ath_pktlog_info_lnx {
106 struct ath_pktlog_info info;
107 struct ctl_table sysctls[PKTLOG_SYSCTL_SIZE];
108 struct proc_dir_entry *proc_entry;
109 struct ctl_table_header *sysctl_header;
110};
111
112#define PL_INFO_LNX(_pl_info) ((struct ath_pktlog_info_lnx *)(_pl_info))
113
114extern struct ol_pktlog_dev_t ol_pl_dev;
115
116/*
117 * WDI related data and functions
118 * Callback function to the WDI events
119 */
120void pktlog_callback(void *pdev, enum WDI_EVENT event, void *log_data);
121
122void pktlog_init(struct ol_softc *scn);
123int pktlog_enable(struct ol_softc *scn, int32_t log_state);
124int pktlog_setsize(struct ol_softc *scn, int32_t log_state);
125int pktlog_disable(struct ol_softc *scn);
126int pktlogmod_init(void *context);
127void pktlogmod_exit(void *context);
128
129#define ol_pktlog_attach(_scn) \
130 do { \
131 if (g_ol_pl_os_dep_funcs) { \
132 g_ol_pl_os_dep_funcs->pktlog_attach(_scn); \
133 } \
134 } while (0)
135
136#define ol_pktlog_detach(_scn) \
137 do { \
138 if (g_ol_pl_os_dep_funcs) { \
139 g_ol_pl_os_dep_funcs->pktlog_detach(_scn); \
140 } \
141 } while (0)
142
143#else /* REMOVE_PKT_LOG */
144#define ol_pktlog_attach(_scn) ({ (void)_scn; })
145#define ol_pktlog_detach(_scn) ({ (void)_scn; })
146static inline void pktlog_init(struct ol_softc *scn)
147{
148 return;
149}
150static int pktlog_enable(struct ol_softc *scn, int32_t log_state)
151{
152 return 0;
153}
154static int pktlog_setsize(struct ol_softc *scn, int32_t log_state)
155{
156 return 0;
157}
158static int pktlog_disable(struct ol_softc *scn)
159{
160 return 0;
161}
162#endif /* REMOVE_PKT_LOG */
163#endif /* _PKTLOG_AC_H_ */