.. | .. |
---|
1 | | -/* |
---|
2 | | - * Copyright (c) 2015 Quantenna Communications |
---|
3 | | - * |
---|
4 | | - * Permission to use, copy, modify, and/or distribute this software for any |
---|
5 | | - * purpose with or without fee is hereby granted, provided that the above |
---|
6 | | - * copyright notice and this permission notice appear in all copies. |
---|
7 | | - * |
---|
8 | | - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
---|
9 | | - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
---|
10 | | - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY |
---|
11 | | - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
---|
12 | | - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION |
---|
13 | | - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN |
---|
14 | | - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
---|
15 | | - */ |
---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0+ */ |
---|
| 2 | +/* Copyright (c) 2015 Quantenna Communications. All rights reserved. */ |
---|
16 | 3 | |
---|
17 | 4 | #ifndef QTNFMAC_BUS_H |
---|
18 | 5 | #define QTNFMAC_BUS_H |
---|
.. | .. |
---|
20 | 7 | #include <linux/netdevice.h> |
---|
21 | 8 | #include <linux/workqueue.h> |
---|
22 | 9 | |
---|
| 10 | +#include "trans.h" |
---|
| 11 | +#include "core.h" |
---|
| 12 | + |
---|
23 | 13 | #define QTNF_MAX_MAC 3 |
---|
24 | 14 | |
---|
| 15 | +#define HBM_FRAME_META_MAGIC_PATTERN_S 0xAB |
---|
| 16 | +#define HBM_FRAME_META_MAGIC_PATTERN_E 0xBA |
---|
| 17 | + |
---|
| 18 | +struct qtnf_frame_meta_info { |
---|
| 19 | + u8 magic_s; |
---|
| 20 | + u8 ifidx; |
---|
| 21 | + u8 macid; |
---|
| 22 | + u8 magic_e; |
---|
| 23 | +} __packed; |
---|
| 24 | + |
---|
25 | 25 | enum qtnf_fw_state { |
---|
26 | | - QTNF_FW_STATE_RESET, |
---|
27 | | - QTNF_FW_STATE_FW_DNLD_DONE, |
---|
| 26 | + QTNF_FW_STATE_DETACHED, |
---|
28 | 27 | QTNF_FW_STATE_BOOT_DONE, |
---|
29 | 28 | QTNF_FW_STATE_ACTIVE, |
---|
30 | | - QTNF_FW_STATE_DETACHED, |
---|
31 | | - QTNF_FW_STATE_EP_DEAD, |
---|
| 29 | + QTNF_FW_STATE_RUNNING, |
---|
| 30 | + QTNF_FW_STATE_DEAD, |
---|
32 | 31 | }; |
---|
33 | 32 | |
---|
34 | 33 | struct qtnf_bus; |
---|
.. | .. |
---|
42 | 41 | int (*control_tx)(struct qtnf_bus *, struct sk_buff *); |
---|
43 | 42 | |
---|
44 | 43 | /* data xfer methods */ |
---|
45 | | - int (*data_tx)(struct qtnf_bus *, struct sk_buff *); |
---|
| 44 | + int (*data_tx)(struct qtnf_bus *bus, struct sk_buff *skb, |
---|
| 45 | + unsigned int macid, unsigned int vifid); |
---|
46 | 46 | void (*data_tx_timeout)(struct qtnf_bus *, struct net_device *); |
---|
| 47 | + void (*data_tx_use_meta_set)(struct qtnf_bus *bus, bool use_meta); |
---|
47 | 48 | void (*data_rx_start)(struct qtnf_bus *); |
---|
48 | 49 | void (*data_rx_stop)(struct qtnf_bus *); |
---|
49 | 50 | }; |
---|
.. | .. |
---|
53 | 54 | enum qtnf_fw_state fw_state; |
---|
54 | 55 | u32 chip; |
---|
55 | 56 | u32 chiprev; |
---|
56 | | - const struct qtnf_bus_ops *bus_ops; |
---|
| 57 | + struct qtnf_bus_ops *bus_ops; |
---|
57 | 58 | struct qtnf_wmac *mac[QTNF_MAX_MAC]; |
---|
58 | 59 | struct qtnf_qlink_transport trans; |
---|
59 | 60 | struct qtnf_hw_info hw_info; |
---|
60 | | - char fwname[32]; |
---|
61 | 61 | struct napi_struct mux_napi; |
---|
62 | 62 | struct net_device mux_dev; |
---|
63 | | - struct completion firmware_init_complete; |
---|
64 | 63 | struct workqueue_struct *workqueue; |
---|
| 64 | + struct workqueue_struct *hprio_workqueue; |
---|
65 | 65 | struct work_struct fw_work; |
---|
66 | 66 | struct work_struct event_work; |
---|
67 | 67 | struct mutex bus_lock; /* lock during command/event processing */ |
---|
68 | 68 | struct dentry *dbg_dir; |
---|
| 69 | + struct notifier_block netdev_nb; |
---|
| 70 | + u8 hw_id[ETH_ALEN]; |
---|
69 | 71 | /* bus private data */ |
---|
70 | | - char bus_priv[0] __aligned(sizeof(void *)); |
---|
| 72 | + char bus_priv[] __aligned(sizeof(void *)); |
---|
71 | 73 | }; |
---|
| 74 | + |
---|
| 75 | +static inline bool qtnf_fw_is_up(struct qtnf_bus *bus) |
---|
| 76 | +{ |
---|
| 77 | + enum qtnf_fw_state state = bus->fw_state; |
---|
| 78 | + |
---|
| 79 | + return ((state == QTNF_FW_STATE_ACTIVE) || |
---|
| 80 | + (state == QTNF_FW_STATE_RUNNING)); |
---|
| 81 | +} |
---|
| 82 | + |
---|
| 83 | +static inline bool qtnf_fw_is_attached(struct qtnf_bus *bus) |
---|
| 84 | +{ |
---|
| 85 | + enum qtnf_fw_state state = bus->fw_state; |
---|
| 86 | + |
---|
| 87 | + return ((state == QTNF_FW_STATE_ACTIVE) || |
---|
| 88 | + (state == QTNF_FW_STATE_RUNNING) || |
---|
| 89 | + (state == QTNF_FW_STATE_DEAD)); |
---|
| 90 | +} |
---|
72 | 91 | |
---|
73 | 92 | static inline void *get_bus_priv(struct qtnf_bus *bus) |
---|
74 | 93 | { |
---|
.. | .. |
---|
94 | 113 | bus->bus_ops->stop(bus); |
---|
95 | 114 | } |
---|
96 | 115 | |
---|
97 | | -static inline int qtnf_bus_data_tx(struct qtnf_bus *bus, struct sk_buff *skb) |
---|
| 116 | +static inline int qtnf_bus_data_tx(struct qtnf_bus *bus, struct sk_buff *skb, |
---|
| 117 | + unsigned int macid, unsigned int vifid) |
---|
98 | 118 | { |
---|
99 | | - return bus->bus_ops->data_tx(bus, skb); |
---|
| 119 | + return bus->bus_ops->data_tx(bus, skb, macid, vifid); |
---|
100 | 120 | } |
---|
101 | 121 | |
---|
102 | 122 | static inline void |
---|
.. | .. |
---|
134 | 154 | |
---|
135 | 155 | int qtnf_core_attach(struct qtnf_bus *bus); |
---|
136 | 156 | void qtnf_core_detach(struct qtnf_bus *bus); |
---|
137 | | -void qtnf_txflowblock(struct device *dev, bool state); |
---|
138 | | -void qtnf_txcomplete(struct device *dev, struct sk_buff *txp, bool success); |
---|
139 | 157 | |
---|
140 | 158 | #endif /* QTNFMAC_BUS_H */ |
---|