1 |
commit: 47a920430b421062371b9f82f620bc48ca5f5602 |
2 |
Author: Alice Ferrazzi <alicef <AT> gentoo <DOT> org> |
3 |
AuthorDate: Fri Apr 16 11:17:03 2021 +0000 |
4 |
Commit: Alice Ferrazzi <alicef <AT> gentoo <DOT> org> |
5 |
CommitDate: Fri Apr 16 11:17:12 2021 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/linux-patches.git/commit/?id=47a92043 |
7 |
|
8 |
Linux patch 4.14.231 |
9 |
|
10 |
Signed-off-by: Alice Ferrazzi <alicef <AT> gentoo.org> |
11 |
|
12 |
0000_README | 4 + |
13 |
1230_linux-4.14.231.patch | 3301 +++++++++++++++++++++++++++++++++++++++++++++ |
14 |
2 files changed, 3305 insertions(+) |
15 |
|
16 |
diff --git a/0000_README b/0000_README |
17 |
index 34eb3e8..8c683a8 100644 |
18 |
--- a/0000_README |
19 |
+++ b/0000_README |
20 |
@@ -963,6 +963,10 @@ Patch: 1229_linux-4.14.230.patch |
21 |
From: https://www.kernel.org |
22 |
Desc: Linux 4.14.230 |
23 |
|
24 |
+Patch: 1230_linux-4.14.231.patch |
25 |
+From: https://www.kernel.org |
26 |
+Desc: Linux 4.14.231 |
27 |
+ |
28 |
Patch: 1500_XATTR_USER_PREFIX.patch |
29 |
From: https://bugs.gentoo.org/show_bug.cgi?id=470644 |
30 |
Desc: Support for namespace user.pax.* on tmpfs. |
31 |
|
32 |
diff --git a/1230_linux-4.14.231.patch b/1230_linux-4.14.231.patch |
33 |
new file mode 100644 |
34 |
index 0000000..9a6d297 |
35 |
--- /dev/null |
36 |
+++ b/1230_linux-4.14.231.patch |
37 |
@@ -0,0 +1,3301 @@ |
38 |
+diff --git a/Makefile b/Makefile |
39 |
+index 09989cdd5caba..cee830aea284c 100644 |
40 |
+--- a/Makefile |
41 |
++++ b/Makefile |
42 |
+@@ -1,7 +1,7 @@ |
43 |
+ # SPDX-License-Identifier: GPL-2.0 |
44 |
+ VERSION = 4 |
45 |
+ PATCHLEVEL = 14 |
46 |
+-SUBLEVEL = 230 |
47 |
++SUBLEVEL = 231 |
48 |
+ EXTRAVERSION = |
49 |
+ NAME = Petit Gorille |
50 |
+ |
51 |
+diff --git a/arch/arm/boot/dts/armada-385-turris-omnia.dts b/arch/arm/boot/dts/armada-385-turris-omnia.dts |
52 |
+index 06831e1e3f808..6c2d96cbd7cdb 100644 |
53 |
+--- a/arch/arm/boot/dts/armada-385-turris-omnia.dts |
54 |
++++ b/arch/arm/boot/dts/armada-385-turris-omnia.dts |
55 |
+@@ -269,6 +269,7 @@ |
56 |
+ status = "okay"; |
57 |
+ compatible = "ethernet-phy-id0141.0DD1", "ethernet-phy-ieee802.3-c22"; |
58 |
+ reg = <1>; |
59 |
++ marvell,reg-init = <3 18 0 0x4985>; |
60 |
+ |
61 |
+ /* irq is connected to &pcawan pin 7 */ |
62 |
+ }; |
63 |
+diff --git a/arch/arm/boot/dts/imx6qdl-phytec-pfla02.dtsi b/arch/arm/boot/dts/imx6qdl-phytec-pfla02.dtsi |
64 |
+index 25b0704c60549..d2c31eae9fef5 100644 |
65 |
+--- a/arch/arm/boot/dts/imx6qdl-phytec-pfla02.dtsi |
66 |
++++ b/arch/arm/boot/dts/imx6qdl-phytec-pfla02.dtsi |
67 |
+@@ -423,6 +423,7 @@ |
68 |
+ pinctrl-0 = <&pinctrl_usdhc2>; |
69 |
+ cd-gpios = <&gpio1 4 GPIO_ACTIVE_LOW>; |
70 |
+ wp-gpios = <&gpio1 2 GPIO_ACTIVE_HIGH>; |
71 |
++ vmmc-supply = <&vdd_sd1_reg>; |
72 |
+ status = "disabled"; |
73 |
+ }; |
74 |
+ |
75 |
+@@ -432,5 +433,6 @@ |
76 |
+ &pinctrl_usdhc3_cdwp>; |
77 |
+ cd-gpios = <&gpio1 27 GPIO_ACTIVE_LOW>; |
78 |
+ wp-gpios = <&gpio1 29 GPIO_ACTIVE_HIGH>; |
79 |
++ vmmc-supply = <&vdd_sd0_reg>; |
80 |
+ status = "disabled"; |
81 |
+ }; |
82 |
+diff --git a/arch/arm64/include/asm/kvm_arm.h b/arch/arm64/include/asm/kvm_arm.h |
83 |
+index f88611e241f0e..72ed11292df3b 100644 |
84 |
+--- a/arch/arm64/include/asm/kvm_arm.h |
85 |
++++ b/arch/arm64/include/asm/kvm_arm.h |
86 |
+@@ -191,6 +191,7 @@ |
87 |
+ #define CPTR_EL2_DEFAULT 0x000033ff |
88 |
+ |
89 |
+ /* Hyp Debug Configuration Register bits */ |
90 |
++#define MDCR_EL2_TTRF (1 << 19) |
91 |
+ #define MDCR_EL2_TPMS (1 << 14) |
92 |
+ #define MDCR_EL2_E2PB_MASK (UL(0x3)) |
93 |
+ #define MDCR_EL2_E2PB_SHIFT (UL(12)) |
94 |
+diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c |
95 |
+index 174aa12fb8b1f..1481e18aa5ca0 100644 |
96 |
+--- a/arch/arm64/kernel/cpufeature.c |
97 |
++++ b/arch/arm64/kernel/cpufeature.c |
98 |
+@@ -230,7 +230,6 @@ static const struct arm64_ftr_bits ftr_id_aa64dfr0[] = { |
99 |
+ * of support. |
100 |
+ */ |
101 |
+ S_ARM64_FTR_BITS(FTR_HIDDEN, FTR_NONSTRICT, FTR_EXACT, ID_AA64DFR0_PMUVER_SHIFT, 4, 0), |
102 |
+- ARM64_FTR_BITS(FTR_HIDDEN, FTR_STRICT, FTR_EXACT, ID_AA64DFR0_TRACEVER_SHIFT, 4, 0), |
103 |
+ ARM64_FTR_BITS(FTR_HIDDEN, FTR_STRICT, FTR_EXACT, ID_AA64DFR0_DEBUGVER_SHIFT, 4, 0x6), |
104 |
+ ARM64_FTR_END, |
105 |
+ }; |
106 |
+diff --git a/arch/arm64/kvm/debug.c b/arch/arm64/kvm/debug.c |
107 |
+index dbadfaf850a7d..2da4f45ab0bbd 100644 |
108 |
+--- a/arch/arm64/kvm/debug.c |
109 |
++++ b/arch/arm64/kvm/debug.c |
110 |
+@@ -96,6 +96,7 @@ void kvm_arm_reset_debug_ptr(struct kvm_vcpu *vcpu) |
111 |
+ * - Debug ROM Address (MDCR_EL2_TDRA) |
112 |
+ * - OS related registers (MDCR_EL2_TDOSA) |
113 |
+ * - Statistical profiler (MDCR_EL2_TPMS/MDCR_EL2_E2PB) |
114 |
++ * - Self-hosted Trace Filter controls (MDCR_EL2_TTRF) |
115 |
+ * |
116 |
+ * Additionally, KVM only traps guest accesses to the debug registers if |
117 |
+ * the guest is not actively using them (see the KVM_ARM64_DEBUG_DIRTY |
118 |
+@@ -118,6 +119,7 @@ void kvm_arm_setup_debug(struct kvm_vcpu *vcpu) |
119 |
+ vcpu->arch.mdcr_el2 = __this_cpu_read(mdcr_el2) & MDCR_EL2_HPMN_MASK; |
120 |
+ vcpu->arch.mdcr_el2 |= (MDCR_EL2_TPM | |
121 |
+ MDCR_EL2_TPMS | |
122 |
++ MDCR_EL2_TTRF | |
123 |
+ MDCR_EL2_TPMCR | |
124 |
+ MDCR_EL2_TDRA | |
125 |
+ MDCR_EL2_TDOSA); |
126 |
+diff --git a/arch/ia64/include/asm/ptrace.h b/arch/ia64/include/asm/ptrace.h |
127 |
+index 7ff574d56429c..f31e07fc936d9 100644 |
128 |
+--- a/arch/ia64/include/asm/ptrace.h |
129 |
++++ b/arch/ia64/include/asm/ptrace.h |
130 |
+@@ -54,8 +54,7 @@ |
131 |
+ |
132 |
+ static inline unsigned long user_stack_pointer(struct pt_regs *regs) |
133 |
+ { |
134 |
+- /* FIXME: should this be bspstore + nr_dirty regs? */ |
135 |
+- return regs->ar_bspstore; |
136 |
++ return regs->r12; |
137 |
+ } |
138 |
+ |
139 |
+ static inline int is_syscall_success(struct pt_regs *regs) |
140 |
+@@ -79,11 +78,6 @@ static inline long regs_return_value(struct pt_regs *regs) |
141 |
+ unsigned long __ip = instruction_pointer(regs); \ |
142 |
+ (__ip & ~3UL) + ((__ip & 3UL) << 2); \ |
143 |
+ }) |
144 |
+-/* |
145 |
+- * Why not default? Because user_stack_pointer() on ia64 gives register |
146 |
+- * stack backing store instead... |
147 |
+- */ |
148 |
+-#define current_user_stack_pointer() (current_pt_regs()->r12) |
149 |
+ |
150 |
+ /* given a pointer to a task_struct, return the user's pt_regs */ |
151 |
+ # define task_pt_regs(t) (((struct pt_regs *) ((char *) (t) + IA64_STK_OFFSET)) - 1) |
152 |
+diff --git a/arch/parisc/include/asm/cmpxchg.h b/arch/parisc/include/asm/cmpxchg.h |
153 |
+index 0689585758717..a736dc59bbef8 100644 |
154 |
+--- a/arch/parisc/include/asm/cmpxchg.h |
155 |
++++ b/arch/parisc/include/asm/cmpxchg.h |
156 |
+@@ -72,7 +72,7 @@ __cmpxchg(volatile void *ptr, unsigned long old, unsigned long new_, int size) |
157 |
+ #endif |
158 |
+ case 4: return __cmpxchg_u32((unsigned int *)ptr, |
159 |
+ (unsigned int)old, (unsigned int)new_); |
160 |
+- case 1: return __cmpxchg_u8((u8 *)ptr, (u8)old, (u8)new_); |
161 |
++ case 1: return __cmpxchg_u8((u8 *)ptr, old & 0xff, new_ & 0xff); |
162 |
+ } |
163 |
+ __cmpxchg_called_with_bad_pointer(); |
164 |
+ return old; |
165 |
+diff --git a/arch/s390/kernel/cpcmd.c b/arch/s390/kernel/cpcmd.c |
166 |
+index af013b4244d34..2da0273597989 100644 |
167 |
+--- a/arch/s390/kernel/cpcmd.c |
168 |
++++ b/arch/s390/kernel/cpcmd.c |
169 |
+@@ -37,10 +37,12 @@ static int diag8_noresponse(int cmdlen) |
170 |
+ |
171 |
+ static int diag8_response(int cmdlen, char *response, int *rlen) |
172 |
+ { |
173 |
++ unsigned long _cmdlen = cmdlen | 0x40000000L; |
174 |
++ unsigned long _rlen = *rlen; |
175 |
+ register unsigned long reg2 asm ("2") = (addr_t) cpcmd_buf; |
176 |
+ register unsigned long reg3 asm ("3") = (addr_t) response; |
177 |
+- register unsigned long reg4 asm ("4") = cmdlen | 0x40000000L; |
178 |
+- register unsigned long reg5 asm ("5") = *rlen; |
179 |
++ register unsigned long reg4 asm ("4") = _cmdlen; |
180 |
++ register unsigned long reg5 asm ("5") = _rlen; |
181 |
+ |
182 |
+ asm volatile( |
183 |
+ " diag %2,%0,0x8\n" |
184 |
+diff --git a/block/bio.c b/block/bio.c |
185 |
+index 1384f97908822..30df1b45dde84 100644 |
186 |
+--- a/block/bio.c |
187 |
++++ b/block/bio.c |
188 |
+@@ -312,7 +312,7 @@ static struct bio *__bio_chain_endio(struct bio *bio) |
189 |
+ { |
190 |
+ struct bio *parent = bio->bi_private; |
191 |
+ |
192 |
+- if (!parent->bi_status) |
193 |
++ if (bio->bi_status && !parent->bi_status) |
194 |
+ parent->bi_status = bio->bi_status; |
195 |
+ bio_put(bio); |
196 |
+ return parent; |
197 |
+diff --git a/drivers/char/agp/Kconfig b/drivers/char/agp/Kconfig |
198 |
+index 6231714ef3c8f..cee9e42ce5478 100644 |
199 |
+--- a/drivers/char/agp/Kconfig |
200 |
++++ b/drivers/char/agp/Kconfig |
201 |
+@@ -125,7 +125,7 @@ config AGP_HP_ZX1 |
202 |
+ |
203 |
+ config AGP_PARISC |
204 |
+ tristate "HP Quicksilver AGP support" |
205 |
+- depends on AGP && PARISC && 64BIT |
206 |
++ depends on AGP && PARISC && 64BIT && IOMMU_SBA |
207 |
+ help |
208 |
+ This option gives you AGP GART support for the HP Quicksilver |
209 |
+ AGP bus adapter on HP PA-RISC machines (Ok, just on the C8000 |
210 |
+diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c |
211 |
+index 4289c519af1be..971a9a5006af0 100644 |
212 |
+--- a/drivers/clk/clk.c |
213 |
++++ b/drivers/clk/clk.c |
214 |
+@@ -3018,20 +3018,19 @@ int clk_notifier_register(struct clk *clk, struct notifier_block *nb) |
215 |
+ /* search the list of notifiers for this clk */ |
216 |
+ list_for_each_entry(cn, &clk_notifier_list, node) |
217 |
+ if (cn->clk == clk) |
218 |
+- break; |
219 |
++ goto found; |
220 |
+ |
221 |
+ /* if clk wasn't in the notifier list, allocate new clk_notifier */ |
222 |
+- if (cn->clk != clk) { |
223 |
+- cn = kzalloc(sizeof(*cn), GFP_KERNEL); |
224 |
+- if (!cn) |
225 |
+- goto out; |
226 |
++ cn = kzalloc(sizeof(*cn), GFP_KERNEL); |
227 |
++ if (!cn) |
228 |
++ goto out; |
229 |
+ |
230 |
+- cn->clk = clk; |
231 |
+- srcu_init_notifier_head(&cn->notifier_head); |
232 |
++ cn->clk = clk; |
233 |
++ srcu_init_notifier_head(&cn->notifier_head); |
234 |
+ |
235 |
+- list_add(&cn->node, &clk_notifier_list); |
236 |
+- } |
237 |
++ list_add(&cn->node, &clk_notifier_list); |
238 |
+ |
239 |
++found: |
240 |
+ ret = srcu_notifier_chain_register(&cn->notifier_head, nb); |
241 |
+ |
242 |
+ clk->core->notifier_count++; |
243 |
+@@ -3056,32 +3055,28 @@ EXPORT_SYMBOL_GPL(clk_notifier_register); |
244 |
+ */ |
245 |
+ int clk_notifier_unregister(struct clk *clk, struct notifier_block *nb) |
246 |
+ { |
247 |
+- struct clk_notifier *cn = NULL; |
248 |
+- int ret = -EINVAL; |
249 |
++ struct clk_notifier *cn; |
250 |
++ int ret = -ENOENT; |
251 |
+ |
252 |
+ if (!clk || !nb) |
253 |
+ return -EINVAL; |
254 |
+ |
255 |
+ clk_prepare_lock(); |
256 |
+ |
257 |
+- list_for_each_entry(cn, &clk_notifier_list, node) |
258 |
+- if (cn->clk == clk) |
259 |
+- break; |
260 |
+- |
261 |
+- if (cn->clk == clk) { |
262 |
+- ret = srcu_notifier_chain_unregister(&cn->notifier_head, nb); |
263 |
++ list_for_each_entry(cn, &clk_notifier_list, node) { |
264 |
++ if (cn->clk == clk) { |
265 |
++ ret = srcu_notifier_chain_unregister(&cn->notifier_head, nb); |
266 |
+ |
267 |
+- clk->core->notifier_count--; |
268 |
++ clk->core->notifier_count--; |
269 |
+ |
270 |
+- /* XXX the notifier code should handle this better */ |
271 |
+- if (!cn->notifier_head.head) { |
272 |
+- srcu_cleanup_notifier_head(&cn->notifier_head); |
273 |
+- list_del(&cn->node); |
274 |
+- kfree(cn); |
275 |
++ /* XXX the notifier code should handle this better */ |
276 |
++ if (!cn->notifier_head.head) { |
277 |
++ srcu_cleanup_notifier_head(&cn->notifier_head); |
278 |
++ list_del(&cn->node); |
279 |
++ kfree(cn); |
280 |
++ } |
281 |
++ break; |
282 |
+ } |
283 |
+- |
284 |
+- } else { |
285 |
+- ret = -ENOENT; |
286 |
+ } |
287 |
+ |
288 |
+ clk_prepare_unlock(); |
289 |
+diff --git a/drivers/clk/socfpga/clk-gate.c b/drivers/clk/socfpga/clk-gate.c |
290 |
+index aa7a6e6a15b65..14918896811d6 100644 |
291 |
+--- a/drivers/clk/socfpga/clk-gate.c |
292 |
++++ b/drivers/clk/socfpga/clk-gate.c |
293 |
+@@ -107,7 +107,7 @@ static unsigned long socfpga_clk_recalc_rate(struct clk_hw *hwclk, |
294 |
+ val = readl(socfpgaclk->div_reg) >> socfpgaclk->shift; |
295 |
+ val &= GENMASK(socfpgaclk->width - 1, 0); |
296 |
+ /* Check for GPIO_DB_CLK by its offset */ |
297 |
+- if ((int) socfpgaclk->div_reg & SOCFPGA_GPIO_DB_CLK_OFFSET) |
298 |
++ if ((uintptr_t) socfpgaclk->div_reg & SOCFPGA_GPIO_DB_CLK_OFFSET) |
299 |
+ div = val + 1; |
300 |
+ else |
301 |
+ div = (1 << val); |
302 |
+diff --git a/drivers/gpu/drm/imx/imx-ldb.c b/drivers/gpu/drm/imx/imx-ldb.c |
303 |
+index d38648a7ef2db..d88ac6f2222ae 100644 |
304 |
+--- a/drivers/gpu/drm/imx/imx-ldb.c |
305 |
++++ b/drivers/gpu/drm/imx/imx-ldb.c |
306 |
+@@ -206,6 +206,11 @@ static void imx_ldb_encoder_enable(struct drm_encoder *encoder) |
307 |
+ int dual = ldb->ldb_ctrl & LDB_SPLIT_MODE_EN; |
308 |
+ int mux = drm_of_encoder_active_port_id(imx_ldb_ch->child, encoder); |
309 |
+ |
310 |
++ if (mux < 0 || mux >= ARRAY_SIZE(ldb->clk_sel)) { |
311 |
++ dev_warn(ldb->dev, "%s: invalid mux %d\n", __func__, mux); |
312 |
++ return; |
313 |
++ } |
314 |
++ |
315 |
+ drm_panel_prepare(imx_ldb_ch->panel); |
316 |
+ |
317 |
+ if (dual) { |
318 |
+@@ -264,6 +269,11 @@ imx_ldb_encoder_atomic_mode_set(struct drm_encoder *encoder, |
319 |
+ int mux = drm_of_encoder_active_port_id(imx_ldb_ch->child, encoder); |
320 |
+ u32 bus_format = imx_ldb_ch->bus_format; |
321 |
+ |
322 |
++ if (mux < 0 || mux >= ARRAY_SIZE(ldb->clk_sel)) { |
323 |
++ dev_warn(ldb->dev, "%s: invalid mux %d\n", __func__, mux); |
324 |
++ return; |
325 |
++ } |
326 |
++ |
327 |
+ if (mode->clock > 170000) { |
328 |
+ dev_warn(ldb->dev, |
329 |
+ "%s: mode exceeds 170 MHz pixel clock\n", __func__); |
330 |
+diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c |
331 |
+index 9f2aa45560e62..39065a5d50fc3 100644 |
332 |
+--- a/drivers/i2c/i2c-core-base.c |
333 |
++++ b/drivers/i2c/i2c-core-base.c |
334 |
+@@ -262,13 +262,14 @@ EXPORT_SYMBOL_GPL(i2c_recover_bus); |
335 |
+ static void i2c_init_recovery(struct i2c_adapter *adap) |
336 |
+ { |
337 |
+ struct i2c_bus_recovery_info *bri = adap->bus_recovery_info; |
338 |
+- char *err_str; |
339 |
++ char *err_str, *err_level = KERN_ERR; |
340 |
+ |
341 |
+ if (!bri) |
342 |
+ return; |
343 |
+ |
344 |
+ if (!bri->recover_bus) { |
345 |
+- err_str = "no recover_bus() found"; |
346 |
++ err_str = "no suitable method provided"; |
347 |
++ err_level = KERN_DEBUG; |
348 |
+ goto err; |
349 |
+ } |
350 |
+ |
351 |
+@@ -296,7 +297,7 @@ static void i2c_init_recovery(struct i2c_adapter *adap) |
352 |
+ |
353 |
+ return; |
354 |
+ err: |
355 |
+- dev_err(&adap->dev, "Not using recovery: %s\n", err_str); |
356 |
++ dev_printk(err_level, &adap->dev, "Not using recovery: %s\n", err_str); |
357 |
+ adap->bus_recovery_info = NULL; |
358 |
+ } |
359 |
+ |
360 |
+diff --git a/drivers/infiniband/hw/cxgb4/cm.c b/drivers/infiniband/hw/cxgb4/cm.c |
361 |
+index 72e2031993fb2..2ea87fe1184d1 100644 |
362 |
+--- a/drivers/infiniband/hw/cxgb4/cm.c |
363 |
++++ b/drivers/infiniband/hw/cxgb4/cm.c |
364 |
+@@ -3498,7 +3498,8 @@ int c4iw_destroy_listen(struct iw_cm_id *cm_id) |
365 |
+ c4iw_init_wr_wait(&ep->com.wr_wait); |
366 |
+ err = cxgb4_remove_server( |
367 |
+ ep->com.dev->rdev.lldi.ports[0], ep->stid, |
368 |
+- ep->com.dev->rdev.lldi.rxq_ids[0], true); |
369 |
++ ep->com.dev->rdev.lldi.rxq_ids[0], |
370 |
++ ep->com.local_addr.ss_family == AF_INET6); |
371 |
+ if (err) |
372 |
+ goto done; |
373 |
+ err = c4iw_wait_for_reply(&ep->com.dev->rdev, &ep->com.wr_wait, |
374 |
+diff --git a/drivers/net/can/usb/peak_usb/pcan_usb_core.c b/drivers/net/can/usb/peak_usb/pcan_usb_core.c |
375 |
+index c9d86d50bf886..3c73eaae5388c 100644 |
376 |
+--- a/drivers/net/can/usb/peak_usb/pcan_usb_core.c |
377 |
++++ b/drivers/net/can/usb/peak_usb/pcan_usb_core.c |
378 |
+@@ -882,7 +882,7 @@ static int peak_usb_create_dev(const struct peak_usb_adapter *peak_usb_adapter, |
379 |
+ if (dev->adapter->dev_set_bus) { |
380 |
+ err = dev->adapter->dev_set_bus(dev, 0); |
381 |
+ if (err) |
382 |
+- goto lbl_unregister_candev; |
383 |
++ goto adap_dev_free; |
384 |
+ } |
385 |
+ |
386 |
+ /* get device number early */ |
387 |
+@@ -894,6 +894,10 @@ static int peak_usb_create_dev(const struct peak_usb_adapter *peak_usb_adapter, |
388 |
+ |
389 |
+ return 0; |
390 |
+ |
391 |
++adap_dev_free: |
392 |
++ if (dev->adapter->dev_free) |
393 |
++ dev->adapter->dev_free(dev); |
394 |
++ |
395 |
+ lbl_unregister_candev: |
396 |
+ unregister_candev(netdev); |
397 |
+ |
398 |
+diff --git a/drivers/net/ethernet/amd/xgbe/xgbe.h b/drivers/net/ethernet/amd/xgbe/xgbe.h |
399 |
+index 95d4b56448c68..cd0459b0055bb 100644 |
400 |
+--- a/drivers/net/ethernet/amd/xgbe/xgbe.h |
401 |
++++ b/drivers/net/ethernet/amd/xgbe/xgbe.h |
402 |
+@@ -176,9 +176,9 @@ |
403 |
+ #define XGBE_DMA_SYS_AWCR 0x30303030 |
404 |
+ |
405 |
+ /* DMA cache settings - PCI device */ |
406 |
+-#define XGBE_DMA_PCI_ARCR 0x00000003 |
407 |
+-#define XGBE_DMA_PCI_AWCR 0x13131313 |
408 |
+-#define XGBE_DMA_PCI_AWARCR 0x00000313 |
409 |
++#define XGBE_DMA_PCI_ARCR 0x000f0f0f |
410 |
++#define XGBE_DMA_PCI_AWCR 0x0f0f0f0f |
411 |
++#define XGBE_DMA_PCI_AWARCR 0x00000f0f |
412 |
+ |
413 |
+ /* DMA channel interrupt modes */ |
414 |
+ #define XGBE_IRQ_MODE_EDGE 0 |
415 |
+diff --git a/drivers/net/ethernet/freescale/gianfar.c b/drivers/net/ethernet/freescale/gianfar.c |
416 |
+index b3b7b98eb32c1..c89a5a80c9c8b 100644 |
417 |
+--- a/drivers/net/ethernet/freescale/gianfar.c |
418 |
++++ b/drivers/net/ethernet/freescale/gianfar.c |
419 |
+@@ -485,7 +485,11 @@ static struct net_device_stats *gfar_get_stats(struct net_device *dev) |
420 |
+ |
421 |
+ static int gfar_set_mac_addr(struct net_device *dev, void *p) |
422 |
+ { |
423 |
+- eth_mac_addr(dev, p); |
424 |
++ int ret; |
425 |
++ |
426 |
++ ret = eth_mac_addr(dev, p); |
427 |
++ if (ret) |
428 |
++ return ret; |
429 |
+ |
430 |
+ gfar_set_mac_for_addr(dev, 0, dev->dev_addr); |
431 |
+ |
432 |
+diff --git a/drivers/net/ieee802154/atusb.c b/drivers/net/ieee802154/atusb.c |
433 |
+index 8e2cbc88df98b..2c4274453c156 100644 |
434 |
+--- a/drivers/net/ieee802154/atusb.c |
435 |
++++ b/drivers/net/ieee802154/atusb.c |
436 |
+@@ -346,6 +346,7 @@ static int atusb_alloc_urbs(struct atusb *atusb, int n) |
437 |
+ return -ENOMEM; |
438 |
+ } |
439 |
+ usb_anchor_urb(urb, &atusb->idle_urbs); |
440 |
++ usb_free_urb(urb); |
441 |
+ n--; |
442 |
+ } |
443 |
+ return 0; |
444 |
+diff --git a/drivers/net/phy/bcm-phy-lib.c b/drivers/net/phy/bcm-phy-lib.c |
445 |
+index d5e0833d69b9b..66e4ef8ed3454 100644 |
446 |
+--- a/drivers/net/phy/bcm-phy-lib.c |
447 |
++++ b/drivers/net/phy/bcm-phy-lib.c |
448 |
+@@ -198,7 +198,7 @@ EXPORT_SYMBOL_GPL(bcm_phy_enable_apd); |
449 |
+ |
450 |
+ int bcm_phy_set_eee(struct phy_device *phydev, bool enable) |
451 |
+ { |
452 |
+- int val; |
453 |
++ int val, mask = 0; |
454 |
+ |
455 |
+ /* Enable EEE at PHY level */ |
456 |
+ val = phy_read_mmd(phydev, MDIO_MMD_AN, BRCM_CL45VEN_EEE_CONTROL); |
457 |
+@@ -217,10 +217,15 @@ int bcm_phy_set_eee(struct phy_device *phydev, bool enable) |
458 |
+ if (val < 0) |
459 |
+ return val; |
460 |
+ |
461 |
++ if (phydev->supported & SUPPORTED_1000baseT_Full) |
462 |
++ mask |= MDIO_EEE_1000T; |
463 |
++ if (phydev->supported & SUPPORTED_100baseT_Full) |
464 |
++ mask |= MDIO_EEE_100TX; |
465 |
++ |
466 |
+ if (enable) |
467 |
+- val |= (MDIO_EEE_100TX | MDIO_EEE_1000T); |
468 |
++ val |= mask; |
469 |
+ else |
470 |
+- val &= ~(MDIO_EEE_100TX | MDIO_EEE_1000T); |
471 |
++ val &= ~mask; |
472 |
+ |
473 |
+ phy_write_mmd(phydev, MDIO_MMD_AN, BCM_CL45VEN_EEE_ADV, (u32)val); |
474 |
+ |
475 |
+diff --git a/drivers/net/tun.c b/drivers/net/tun.c |
476 |
+index abf9c9952b799..2bf58239bd4b4 100644 |
477 |
+--- a/drivers/net/tun.c |
478 |
++++ b/drivers/net/tun.c |
479 |
+@@ -75,6 +75,14 @@ |
480 |
+ #include <linux/skb_array.h> |
481 |
+ #include <linux/bpf.h> |
482 |
+ #include <linux/bpf_trace.h> |
483 |
++#include <linux/ieee802154.h> |
484 |
++#include <linux/if_ltalk.h> |
485 |
++#include <uapi/linux/if_fddi.h> |
486 |
++#include <uapi/linux/if_hippi.h> |
487 |
++#include <uapi/linux/if_fc.h> |
488 |
++#include <net/ax25.h> |
489 |
++#include <net/rose.h> |
490 |
++#include <net/6lowpan.h> |
491 |
+ |
492 |
+ #include <linux/uaccess.h> |
493 |
+ |
494 |
+@@ -2292,6 +2300,45 @@ unlock: |
495 |
+ return ret; |
496 |
+ } |
497 |
+ |
498 |
++/* Return correct value for tun->dev->addr_len based on tun->dev->type. */ |
499 |
++static unsigned char tun_get_addr_len(unsigned short type) |
500 |
++{ |
501 |
++ switch (type) { |
502 |
++ case ARPHRD_IP6GRE: |
503 |
++ case ARPHRD_TUNNEL6: |
504 |
++ return sizeof(struct in6_addr); |
505 |
++ case ARPHRD_IPGRE: |
506 |
++ case ARPHRD_TUNNEL: |
507 |
++ case ARPHRD_SIT: |
508 |
++ return 4; |
509 |
++ case ARPHRD_ETHER: |
510 |
++ return ETH_ALEN; |
511 |
++ case ARPHRD_IEEE802154: |
512 |
++ case ARPHRD_IEEE802154_MONITOR: |
513 |
++ return IEEE802154_EXTENDED_ADDR_LEN; |
514 |
++ case ARPHRD_PHONET_PIPE: |
515 |
++ case ARPHRD_PPP: |
516 |
++ case ARPHRD_NONE: |
517 |
++ return 0; |
518 |
++ case ARPHRD_6LOWPAN: |
519 |
++ return EUI64_ADDR_LEN; |
520 |
++ case ARPHRD_FDDI: |
521 |
++ return FDDI_K_ALEN; |
522 |
++ case ARPHRD_HIPPI: |
523 |
++ return HIPPI_ALEN; |
524 |
++ case ARPHRD_IEEE802: |
525 |
++ return FC_ALEN; |
526 |
++ case ARPHRD_ROSE: |
527 |
++ return ROSE_ADDR_LEN; |
528 |
++ case ARPHRD_NETROM: |
529 |
++ return AX25_ADDR_LEN; |
530 |
++ case ARPHRD_LOCALTLK: |
531 |
++ return LTALK_ALEN; |
532 |
++ default: |
533 |
++ return 0; |
534 |
++ } |
535 |
++} |
536 |
++ |
537 |
+ static long __tun_chr_ioctl(struct file *file, unsigned int cmd, |
538 |
+ unsigned long arg, int ifreq_len) |
539 |
+ { |
540 |
+@@ -2434,6 +2481,7 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd, |
541 |
+ ret = -EBUSY; |
542 |
+ } else { |
543 |
+ tun->dev->type = (int) arg; |
544 |
++ tun->dev->addr_len = tun_get_addr_len(tun->dev->type); |
545 |
+ tun_debug(KERN_INFO, tun, "linktype set to %d\n", |
546 |
+ tun->dev->type); |
547 |
+ ret = 0; |
548 |
+diff --git a/drivers/regulator/bd9571mwv-regulator.c b/drivers/regulator/bd9571mwv-regulator.c |
549 |
+index c67a83d53c4cb..167c05029f9e8 100644 |
550 |
+--- a/drivers/regulator/bd9571mwv-regulator.c |
551 |
++++ b/drivers/regulator/bd9571mwv-regulator.c |
552 |
+@@ -119,7 +119,7 @@ static struct regulator_ops vid_ops = { |
553 |
+ |
554 |
+ static struct regulator_desc regulators[] = { |
555 |
+ BD9571MWV_REG("VD09", "vd09", VD09, avs_ops, 0, 0x7f, |
556 |
+- 0x80, 600000, 10000, 0x3c), |
557 |
++ 0x6f, 600000, 10000, 0x3c), |
558 |
+ BD9571MWV_REG("VD18", "vd18", VD18, vid_ops, BD9571MWV_VD18_VID, 0xf, |
559 |
+ 16, 1625000, 25000, 0), |
560 |
+ BD9571MWV_REG("VD25", "vd25", VD25, vid_ops, BD9571MWV_VD25_VID, 0xf, |
561 |
+@@ -128,7 +128,7 @@ static struct regulator_desc regulators[] = { |
562 |
+ 11, 2800000, 100000, 0), |
563 |
+ BD9571MWV_REG("DVFS", "dvfs", DVFS, reg_ops, |
564 |
+ BD9571MWV_DVFS_MONIVDAC, 0x7f, |
565 |
+- 0x80, 600000, 10000, 0x3c), |
566 |
++ 0x6f, 600000, 10000, 0x3c), |
567 |
+ }; |
568 |
+ |
569 |
+ static int bd9571mwv_regulator_probe(struct platform_device *pdev) |
570 |
+diff --git a/drivers/soc/fsl/qbman/qman.c b/drivers/soc/fsl/qbman/qman.c |
571 |
+index 90892a360c61c..06b6d7afc5671 100644 |
572 |
+--- a/drivers/soc/fsl/qbman/qman.c |
573 |
++++ b/drivers/soc/fsl/qbman/qman.c |
574 |
+@@ -146,7 +146,7 @@ struct qm_eqcr_entry { |
575 |
+ __be32 tag; |
576 |
+ struct qm_fd fd; |
577 |
+ u8 __reserved3[32]; |
578 |
+-} __packed; |
579 |
++} __packed __aligned(8); |
580 |
+ #define QM_EQCR_VERB_VBIT 0x80 |
581 |
+ #define QM_EQCR_VERB_CMD_MASK 0x61 /* but only one value; */ |
582 |
+ #define QM_EQCR_VERB_CMD_ENQUEUE 0x01 |
583 |
+diff --git a/drivers/usb/usbip/stub_dev.c b/drivers/usb/usbip/stub_dev.c |
584 |
+index c6be9923502b5..1b3aad59d6c96 100644 |
585 |
+--- a/drivers/usb/usbip/stub_dev.c |
586 |
++++ b/drivers/usb/usbip/stub_dev.c |
587 |
+@@ -77,6 +77,7 @@ static ssize_t store_sockfd(struct device *dev, struct device_attribute *attr, |
588 |
+ |
589 |
+ dev_info(dev, "stub up\n"); |
590 |
+ |
591 |
++ mutex_lock(&sdev->ud.sysfs_lock); |
592 |
+ spin_lock_irq(&sdev->ud.lock); |
593 |
+ |
594 |
+ if (sdev->ud.status != SDEV_ST_AVAILABLE) { |
595 |
+@@ -101,13 +102,13 @@ static ssize_t store_sockfd(struct device *dev, struct device_attribute *attr, |
596 |
+ tcp_rx = kthread_create(stub_rx_loop, &sdev->ud, "stub_rx"); |
597 |
+ if (IS_ERR(tcp_rx)) { |
598 |
+ sockfd_put(socket); |
599 |
+- return -EINVAL; |
600 |
++ goto unlock_mutex; |
601 |
+ } |
602 |
+ tcp_tx = kthread_create(stub_tx_loop, &sdev->ud, "stub_tx"); |
603 |
+ if (IS_ERR(tcp_tx)) { |
604 |
+ kthread_stop(tcp_rx); |
605 |
+ sockfd_put(socket); |
606 |
+- return -EINVAL; |
607 |
++ goto unlock_mutex; |
608 |
+ } |
609 |
+ |
610 |
+ /* get task structs now */ |
611 |
+@@ -126,6 +127,8 @@ static ssize_t store_sockfd(struct device *dev, struct device_attribute *attr, |
612 |
+ wake_up_process(sdev->ud.tcp_rx); |
613 |
+ wake_up_process(sdev->ud.tcp_tx); |
614 |
+ |
615 |
++ mutex_unlock(&sdev->ud.sysfs_lock); |
616 |
++ |
617 |
+ } else { |
618 |
+ dev_info(dev, "stub down\n"); |
619 |
+ |
620 |
+@@ -136,6 +139,7 @@ static ssize_t store_sockfd(struct device *dev, struct device_attribute *attr, |
621 |
+ spin_unlock_irq(&sdev->ud.lock); |
622 |
+ |
623 |
+ usbip_event_add(&sdev->ud, SDEV_EVENT_DOWN); |
624 |
++ mutex_unlock(&sdev->ud.sysfs_lock); |
625 |
+ } |
626 |
+ |
627 |
+ return count; |
628 |
+@@ -144,6 +148,8 @@ sock_err: |
629 |
+ sockfd_put(socket); |
630 |
+ err: |
631 |
+ spin_unlock_irq(&sdev->ud.lock); |
632 |
++unlock_mutex: |
633 |
++ mutex_unlock(&sdev->ud.sysfs_lock); |
634 |
+ return -EINVAL; |
635 |
+ } |
636 |
+ static DEVICE_ATTR(usbip_sockfd, S_IWUSR, NULL, store_sockfd); |
637 |
+@@ -309,6 +315,7 @@ static struct stub_device *stub_device_alloc(struct usb_device *udev) |
638 |
+ sdev->ud.side = USBIP_STUB; |
639 |
+ sdev->ud.status = SDEV_ST_AVAILABLE; |
640 |
+ spin_lock_init(&sdev->ud.lock); |
641 |
++ mutex_init(&sdev->ud.sysfs_lock); |
642 |
+ sdev->ud.tcp_socket = NULL; |
643 |
+ sdev->ud.sockfd = -1; |
644 |
+ |
645 |
+diff --git a/drivers/usb/usbip/usbip_common.h b/drivers/usb/usbip/usbip_common.h |
646 |
+index 59097145cfc02..d740aa8a12319 100644 |
647 |
+--- a/drivers/usb/usbip/usbip_common.h |
648 |
++++ b/drivers/usb/usbip/usbip_common.h |
649 |
+@@ -277,6 +277,9 @@ struct usbip_device { |
650 |
+ /* lock for status */ |
651 |
+ spinlock_t lock; |
652 |
+ |
653 |
++ /* mutex for synchronizing sysfs store paths */ |
654 |
++ struct mutex sysfs_lock; |
655 |
++ |
656 |
+ int sockfd; |
657 |
+ struct socket *tcp_socket; |
658 |
+ |
659 |
+diff --git a/drivers/usb/usbip/usbip_event.c b/drivers/usb/usbip/usbip_event.c |
660 |
+index f8f7f3803a99c..01eaae1f265b2 100644 |
661 |
+--- a/drivers/usb/usbip/usbip_event.c |
662 |
++++ b/drivers/usb/usbip/usbip_event.c |
663 |
+@@ -84,6 +84,7 @@ static void event_handler(struct work_struct *work) |
664 |
+ while ((ud = get_event()) != NULL) { |
665 |
+ usbip_dbg_eh("pending event %lx\n", ud->event); |
666 |
+ |
667 |
++ mutex_lock(&ud->sysfs_lock); |
668 |
+ /* |
669 |
+ * NOTE: shutdown must come first. |
670 |
+ * Shutdown the device. |
671 |
+@@ -104,6 +105,7 @@ static void event_handler(struct work_struct *work) |
672 |
+ ud->eh_ops.unusable(ud); |
673 |
+ unset_event(ud, USBIP_EH_UNUSABLE); |
674 |
+ } |
675 |
++ mutex_unlock(&ud->sysfs_lock); |
676 |
+ |
677 |
+ wake_up(&ud->eh_waitq); |
678 |
+ } |
679 |
+diff --git a/drivers/usb/usbip/vhci_hcd.c b/drivers/usb/usbip/vhci_hcd.c |
680 |
+index d87159e6c716d..9833f307d70e4 100644 |
681 |
+--- a/drivers/usb/usbip/vhci_hcd.c |
682 |
++++ b/drivers/usb/usbip/vhci_hcd.c |
683 |
+@@ -1115,6 +1115,7 @@ static void vhci_device_init(struct vhci_device *vdev) |
684 |
+ vdev->ud.side = USBIP_VHCI; |
685 |
+ vdev->ud.status = VDEV_ST_NULL; |
686 |
+ spin_lock_init(&vdev->ud.lock); |
687 |
++ mutex_init(&vdev->ud.sysfs_lock); |
688 |
+ |
689 |
+ INIT_LIST_HEAD(&vdev->priv_rx); |
690 |
+ INIT_LIST_HEAD(&vdev->priv_tx); |
691 |
+diff --git a/drivers/usb/usbip/vhci_sysfs.c b/drivers/usb/usbip/vhci_sysfs.c |
692 |
+index 4f0f65540888f..aa329d752015d 100644 |
693 |
+--- a/drivers/usb/usbip/vhci_sysfs.c |
694 |
++++ b/drivers/usb/usbip/vhci_sysfs.c |
695 |
+@@ -199,6 +199,8 @@ static int vhci_port_disconnect(struct vhci_hcd *vhci_hcd, __u32 rhport) |
696 |
+ |
697 |
+ usbip_dbg_vhci_sysfs("enter\n"); |
698 |
+ |
699 |
++ mutex_lock(&vdev->ud.sysfs_lock); |
700 |
++ |
701 |
+ /* lock */ |
702 |
+ spin_lock_irqsave(&vhci->lock, flags); |
703 |
+ spin_lock(&vdev->ud.lock); |
704 |
+@@ -209,6 +211,7 @@ static int vhci_port_disconnect(struct vhci_hcd *vhci_hcd, __u32 rhport) |
705 |
+ /* unlock */ |
706 |
+ spin_unlock(&vdev->ud.lock); |
707 |
+ spin_unlock_irqrestore(&vhci->lock, flags); |
708 |
++ mutex_unlock(&vdev->ud.sysfs_lock); |
709 |
+ |
710 |
+ return -EINVAL; |
711 |
+ } |
712 |
+@@ -219,6 +222,8 @@ static int vhci_port_disconnect(struct vhci_hcd *vhci_hcd, __u32 rhport) |
713 |
+ |
714 |
+ usbip_event_add(&vdev->ud, VDEV_EVENT_DOWN); |
715 |
+ |
716 |
++ mutex_unlock(&vdev->ud.sysfs_lock); |
717 |
++ |
718 |
+ return 0; |
719 |
+ } |
720 |
+ |
721 |
+@@ -363,30 +368,36 @@ static ssize_t store_attach(struct device *dev, struct device_attribute *attr, |
722 |
+ else |
723 |
+ vdev = &vhci->vhci_hcd_hs->vdev[rhport]; |
724 |
+ |
725 |
++ mutex_lock(&vdev->ud.sysfs_lock); |
726 |
++ |
727 |
+ /* Extract socket from fd. */ |
728 |
+ socket = sockfd_lookup(sockfd, &err); |
729 |
+ if (!socket) { |
730 |
+ dev_err(dev, "failed to lookup sock"); |
731 |
+- return -EINVAL; |
732 |
++ err = -EINVAL; |
733 |
++ goto unlock_mutex; |
734 |
+ } |
735 |
+ if (socket->type != SOCK_STREAM) { |
736 |
+ dev_err(dev, "Expecting SOCK_STREAM - found %d", |
737 |
+ socket->type); |
738 |
+ sockfd_put(socket); |
739 |
+- return -EINVAL; |
740 |
++ err = -EINVAL; |
741 |
++ goto unlock_mutex; |
742 |
+ } |
743 |
+ |
744 |
+ /* create threads before locking */ |
745 |
+ tcp_rx = kthread_create(vhci_rx_loop, &vdev->ud, "vhci_rx"); |
746 |
+ if (IS_ERR(tcp_rx)) { |
747 |
+ sockfd_put(socket); |
748 |
+- return -EINVAL; |
749 |
++ err = -EINVAL; |
750 |
++ goto unlock_mutex; |
751 |
+ } |
752 |
+ tcp_tx = kthread_create(vhci_tx_loop, &vdev->ud, "vhci_tx"); |
753 |
+ if (IS_ERR(tcp_tx)) { |
754 |
+ kthread_stop(tcp_rx); |
755 |
+ sockfd_put(socket); |
756 |
+- return -EINVAL; |
757 |
++ err = -EINVAL; |
758 |
++ goto unlock_mutex; |
759 |
+ } |
760 |
+ |
761 |
+ /* get task structs now */ |
762 |
+@@ -411,7 +422,8 @@ static ssize_t store_attach(struct device *dev, struct device_attribute *attr, |
763 |
+ * Will be retried from userspace |
764 |
+ * if there's another free port. |
765 |
+ */ |
766 |
+- return -EBUSY; |
767 |
++ err = -EBUSY; |
768 |
++ goto unlock_mutex; |
769 |
+ } |
770 |
+ |
771 |
+ dev_info(dev, "pdev(%u) rhport(%u) sockfd(%d)\n", |
772 |
+@@ -436,7 +448,15 @@ static ssize_t store_attach(struct device *dev, struct device_attribute *attr, |
773 |
+ |
774 |
+ rh_port_connect(vdev, speed); |
775 |
+ |
776 |
++ dev_info(dev, "Device attached\n"); |
777 |
++ |
778 |
++ mutex_unlock(&vdev->ud.sysfs_lock); |
779 |
++ |
780 |
+ return count; |
781 |
++ |
782 |
++unlock_mutex: |
783 |
++ mutex_unlock(&vdev->ud.sysfs_lock); |
784 |
++ return err; |
785 |
+ } |
786 |
+ static DEVICE_ATTR(attach, S_IWUSR, NULL, store_attach); |
787 |
+ |
788 |
+diff --git a/drivers/usb/usbip/vudc_sysfs.c b/drivers/usb/usbip/vudc_sysfs.c |
789 |
+index e3f7c76d19562..f44d98eeb36ac 100644 |
790 |
+--- a/drivers/usb/usbip/vudc_sysfs.c |
791 |
++++ b/drivers/usb/usbip/vudc_sysfs.c |
792 |
+@@ -103,8 +103,9 @@ unlock: |
793 |
+ } |
794 |
+ static BIN_ATTR_RO(dev_desc, sizeof(struct usb_device_descriptor)); |
795 |
+ |
796 |
+-static ssize_t store_sockfd(struct device *dev, struct device_attribute *attr, |
797 |
+- const char *in, size_t count) |
798 |
++static ssize_t store_sockfd(struct device *dev, |
799 |
++ struct device_attribute *attr, |
800 |
++ const char *in, size_t count) |
801 |
+ { |
802 |
+ struct vudc *udc = (struct vudc *) dev_get_drvdata(dev); |
803 |
+ int rv; |
804 |
+@@ -113,6 +114,8 @@ static ssize_t store_sockfd(struct device *dev, struct device_attribute *attr, |
805 |
+ struct socket *socket; |
806 |
+ unsigned long flags; |
807 |
+ int ret; |
808 |
++ struct task_struct *tcp_rx = NULL; |
809 |
++ struct task_struct *tcp_tx = NULL; |
810 |
+ |
811 |
+ rv = kstrtoint(in, 0, &sockfd); |
812 |
+ if (rv != 0) |
813 |
+@@ -158,24 +161,47 @@ static ssize_t store_sockfd(struct device *dev, struct device_attribute *attr, |
814 |
+ goto sock_err; |
815 |
+ } |
816 |
+ |
817 |
+- udc->ud.tcp_socket = socket; |
818 |
+- |
819 |
++ /* unlock and create threads and get tasks */ |
820 |
+ spin_unlock_irq(&udc->ud.lock); |
821 |
+ spin_unlock_irqrestore(&udc->lock, flags); |
822 |
+ |
823 |
+- udc->ud.tcp_rx = kthread_get_run(&v_rx_loop, |
824 |
+- &udc->ud, "vudc_rx"); |
825 |
+- udc->ud.tcp_tx = kthread_get_run(&v_tx_loop, |
826 |
+- &udc->ud, "vudc_tx"); |
827 |
++ tcp_rx = kthread_create(&v_rx_loop, &udc->ud, "vudc_rx"); |
828 |
++ if (IS_ERR(tcp_rx)) { |
829 |
++ sockfd_put(socket); |
830 |
++ return -EINVAL; |
831 |
++ } |
832 |
++ tcp_tx = kthread_create(&v_tx_loop, &udc->ud, "vudc_tx"); |
833 |
++ if (IS_ERR(tcp_tx)) { |
834 |
++ kthread_stop(tcp_rx); |
835 |
++ sockfd_put(socket); |
836 |
++ return -EINVAL; |
837 |
++ } |
838 |
++ |
839 |
++ /* get task structs now */ |
840 |
++ get_task_struct(tcp_rx); |
841 |
++ get_task_struct(tcp_tx); |
842 |
+ |
843 |
++ /* lock and update udc->ud state */ |
844 |
+ spin_lock_irqsave(&udc->lock, flags); |
845 |
+ spin_lock_irq(&udc->ud.lock); |
846 |
++ |
847 |
++ udc->ud.tcp_socket = socket; |
848 |
++ udc->ud.tcp_rx = tcp_rx; |
849 |
++ udc->ud.tcp_rx = tcp_tx; |
850 |
+ udc->ud.status = SDEV_ST_USED; |
851 |
++ |
852 |
+ spin_unlock_irq(&udc->ud.lock); |
853 |
+ |
854 |
+ do_gettimeofday(&udc->start_time); |
855 |
+ v_start_timer(udc); |
856 |
+ udc->connected = 1; |
857 |
++ |
858 |
++ spin_unlock_irqrestore(&udc->lock, flags); |
859 |
++ |
860 |
++ wake_up_process(udc->ud.tcp_rx); |
861 |
++ wake_up_process(udc->ud.tcp_tx); |
862 |
++ return count; |
863 |
++ |
864 |
+ } else { |
865 |
+ if (!udc->connected) { |
866 |
+ dev_err(dev, "Device not connected"); |
867 |
+diff --git a/drivers/xen/events/events_base.c b/drivers/xen/events/events_base.c |
868 |
+index fae2a536acc67..b370144682ed5 100644 |
869 |
+--- a/drivers/xen/events/events_base.c |
870 |
++++ b/drivers/xen/events/events_base.c |
871 |
+@@ -221,7 +221,7 @@ static int xen_irq_info_common_setup(struct irq_info *info, |
872 |
+ info->evtchn = evtchn; |
873 |
+ info->cpu = cpu; |
874 |
+ info->mask_reason = EVT_MASK_REASON_EXPLICIT; |
875 |
+- spin_lock_init(&info->lock); |
876 |
++ raw_spin_lock_init(&info->lock); |
877 |
+ |
878 |
+ ret = set_evtchn_to_irq(evtchn, irq); |
879 |
+ if (ret < 0) |
880 |
+@@ -373,28 +373,28 @@ static void do_mask(struct irq_info *info, u8 reason) |
881 |
+ { |
882 |
+ unsigned long flags; |
883 |
+ |
884 |
+- spin_lock_irqsave(&info->lock, flags); |
885 |
++ raw_spin_lock_irqsave(&info->lock, flags); |
886 |
+ |
887 |
+ if (!info->mask_reason) |
888 |
+ mask_evtchn(info->evtchn); |
889 |
+ |
890 |
+ info->mask_reason |= reason; |
891 |
+ |
892 |
+- spin_unlock_irqrestore(&info->lock, flags); |
893 |
++ raw_spin_unlock_irqrestore(&info->lock, flags); |
894 |
+ } |
895 |
+ |
896 |
+ static void do_unmask(struct irq_info *info, u8 reason) |
897 |
+ { |
898 |
+ unsigned long flags; |
899 |
+ |
900 |
+- spin_lock_irqsave(&info->lock, flags); |
901 |
++ raw_spin_lock_irqsave(&info->lock, flags); |
902 |
+ |
903 |
+ info->mask_reason &= ~reason; |
904 |
+ |
905 |
+ if (!info->mask_reason) |
906 |
+ unmask_evtchn(info->evtchn); |
907 |
+ |
908 |
+- spin_unlock_irqrestore(&info->lock, flags); |
909 |
++ raw_spin_unlock_irqrestore(&info->lock, flags); |
910 |
+ } |
911 |
+ |
912 |
+ #ifdef CONFIG_X86 |
913 |
+@@ -1782,7 +1782,7 @@ static void lateeoi_ack_dynirq(struct irq_data *data) |
914 |
+ |
915 |
+ if (VALID_EVTCHN(evtchn)) { |
916 |
+ do_mask(info, EVT_MASK_REASON_EOI_PENDING); |
917 |
+- event_handler_exit(info); |
918 |
++ ack_dynirq(data); |
919 |
+ } |
920 |
+ } |
921 |
+ |
922 |
+@@ -1793,7 +1793,7 @@ static void lateeoi_mask_ack_dynirq(struct irq_data *data) |
923 |
+ |
924 |
+ if (VALID_EVTCHN(evtchn)) { |
925 |
+ do_mask(info, EVT_MASK_REASON_EXPLICIT); |
926 |
+- event_handler_exit(info); |
927 |
++ ack_dynirq(data); |
928 |
+ } |
929 |
+ } |
930 |
+ |
931 |
+diff --git a/drivers/xen/events/events_internal.h b/drivers/xen/events/events_internal.h |
932 |
+index 3df6f28b75e69..cc37b711491ce 100644 |
933 |
+--- a/drivers/xen/events/events_internal.h |
934 |
++++ b/drivers/xen/events/events_internal.h |
935 |
+@@ -47,7 +47,7 @@ struct irq_info { |
936 |
+ unsigned short eoi_cpu; /* EOI must happen on this cpu */ |
937 |
+ unsigned int irq_epoch; /* If eoi_cpu valid: irq_epoch of event */ |
938 |
+ u64 eoi_time; /* Time in jiffies when to EOI. */ |
939 |
+- spinlock_t lock; |
940 |
++ raw_spinlock_t lock; |
941 |
+ |
942 |
+ union { |
943 |
+ unsigned short virq; |
944 |
+diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c |
945 |
+index e7c46368cf696..73be08ea135f6 100644 |
946 |
+--- a/fs/cifs/connect.c |
947 |
++++ b/fs/cifs/connect.c |
948 |
+@@ -3607,7 +3607,6 @@ int cifs_setup_cifs_sb(struct smb_vol *pvolume_info, |
949 |
+ cifs_sb->prepath = kstrdup(pvolume_info->prepath, GFP_KERNEL); |
950 |
+ if (cifs_sb->prepath == NULL) |
951 |
+ return -ENOMEM; |
952 |
+- cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_USE_PREFIX_PATH; |
953 |
+ } |
954 |
+ |
955 |
+ return 0; |
956 |
+diff --git a/fs/direct-io.c b/fs/direct-io.c |
957 |
+index 30bf22c989dee..8d9689aac5f4c 100644 |
958 |
+--- a/fs/direct-io.c |
959 |
++++ b/fs/direct-io.c |
960 |
+@@ -857,6 +857,7 @@ submit_page_section(struct dio *dio, struct dio_submit *sdio, struct page *page, |
961 |
+ struct buffer_head *map_bh) |
962 |
+ { |
963 |
+ int ret = 0; |
964 |
++ int boundary = sdio->boundary; /* dio_send_cur_page may clear it */ |
965 |
+ |
966 |
+ if (dio->op == REQ_OP_WRITE) { |
967 |
+ /* |
968 |
+@@ -895,10 +896,10 @@ submit_page_section(struct dio *dio, struct dio_submit *sdio, struct page *page, |
969 |
+ sdio->cur_page_fs_offset = sdio->block_in_file << sdio->blkbits; |
970 |
+ out: |
971 |
+ /* |
972 |
+- * If sdio->boundary then we want to schedule the IO now to |
973 |
++ * If boundary then we want to schedule the IO now to |
974 |
+ * avoid metadata seeks. |
975 |
+ */ |
976 |
+- if (sdio->boundary) { |
977 |
++ if (boundary) { |
978 |
+ ret = dio_send_cur_page(dio, sdio, map_bh); |
979 |
+ if (sdio->bio) |
980 |
+ dio_bio_submit(dio, sdio); |
981 |
+diff --git a/fs/gfs2/super.c b/fs/gfs2/super.c |
982 |
+index bcf95ec1bc31d..56bfed0a58731 100644 |
983 |
+--- a/fs/gfs2/super.c |
984 |
++++ b/fs/gfs2/super.c |
985 |
+@@ -989,11 +989,13 @@ void gfs2_freeze_func(struct work_struct *work) |
986 |
+ static int gfs2_freeze(struct super_block *sb) |
987 |
+ { |
988 |
+ struct gfs2_sbd *sdp = sb->s_fs_info; |
989 |
+- int error = 0; |
990 |
++ int error; |
991 |
+ |
992 |
+ mutex_lock(&sdp->sd_freeze_mutex); |
993 |
+- if (atomic_read(&sdp->sd_freeze_state) != SFS_UNFROZEN) |
994 |
++ if (atomic_read(&sdp->sd_freeze_state) != SFS_UNFROZEN) { |
995 |
++ error = -EBUSY; |
996 |
+ goto out; |
997 |
++ } |
998 |
+ |
999 |
+ if (test_bit(SDF_SHUTDOWN, &sdp->sd_flags)) { |
1000 |
+ error = -EINVAL; |
1001 |
+@@ -1035,10 +1037,10 @@ static int gfs2_unfreeze(struct super_block *sb) |
1002 |
+ struct gfs2_sbd *sdp = sb->s_fs_info; |
1003 |
+ |
1004 |
+ mutex_lock(&sdp->sd_freeze_mutex); |
1005 |
+- if (atomic_read(&sdp->sd_freeze_state) != SFS_FROZEN || |
1006 |
++ if (atomic_read(&sdp->sd_freeze_state) != SFS_FROZEN || |
1007 |
+ !gfs2_holder_initialized(&sdp->sd_freeze_gh)) { |
1008 |
+ mutex_unlock(&sdp->sd_freeze_mutex); |
1009 |
+- return 0; |
1010 |
++ return -EINVAL; |
1011 |
+ } |
1012 |
+ |
1013 |
+ gfs2_glock_dq_uninit(&sdp->sd_freeze_gh); |
1014 |
+diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c |
1015 |
+index 7de0c9562b707..ca2b575a1e461 100644 |
1016 |
+--- a/fs/ocfs2/aops.c |
1017 |
++++ b/fs/ocfs2/aops.c |
1018 |
+@@ -2309,7 +2309,7 @@ static int ocfs2_dio_end_io_write(struct inode *inode, |
1019 |
+ struct ocfs2_alloc_context *meta_ac = NULL; |
1020 |
+ handle_t *handle = NULL; |
1021 |
+ loff_t end = offset + bytes; |
1022 |
+- int ret = 0, credits = 0, locked = 0; |
1023 |
++ int ret = 0, credits = 0; |
1024 |
+ |
1025 |
+ ocfs2_init_dealloc_ctxt(&dealloc); |
1026 |
+ |
1027 |
+@@ -2320,13 +2320,6 @@ static int ocfs2_dio_end_io_write(struct inode *inode, |
1028 |
+ !dwc->dw_orphaned) |
1029 |
+ goto out; |
1030 |
+ |
1031 |
+- /* ocfs2_file_write_iter will get i_mutex, so we need not lock if we |
1032 |
+- * are in that context. */ |
1033 |
+- if (dwc->dw_writer_pid != task_pid_nr(current)) { |
1034 |
+- inode_lock(inode); |
1035 |
+- locked = 1; |
1036 |
+- } |
1037 |
+- |
1038 |
+ ret = ocfs2_inode_lock(inode, &di_bh, 1); |
1039 |
+ if (ret < 0) { |
1040 |
+ mlog_errno(ret); |
1041 |
+@@ -2401,8 +2394,6 @@ out: |
1042 |
+ if (meta_ac) |
1043 |
+ ocfs2_free_alloc_context(meta_ac); |
1044 |
+ ocfs2_run_deallocs(osb, &dealloc); |
1045 |
+- if (locked) |
1046 |
+- inode_unlock(inode); |
1047 |
+ ocfs2_dio_free_write_ctx(inode, dwc); |
1048 |
+ |
1049 |
+ return ret; |
1050 |
+diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c |
1051 |
+index dc455d45a66ae..baf5c4028fd62 100644 |
1052 |
+--- a/fs/ocfs2/file.c |
1053 |
++++ b/fs/ocfs2/file.c |
1054 |
+@@ -1250,22 +1250,24 @@ int ocfs2_setattr(struct dentry *dentry, struct iattr *attr) |
1055 |
+ goto bail_unlock; |
1056 |
+ } |
1057 |
+ } |
1058 |
++ down_write(&OCFS2_I(inode)->ip_alloc_sem); |
1059 |
+ handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS + |
1060 |
+ 2 * ocfs2_quota_trans_credits(sb)); |
1061 |
+ if (IS_ERR(handle)) { |
1062 |
+ status = PTR_ERR(handle); |
1063 |
+ mlog_errno(status); |
1064 |
+- goto bail_unlock; |
1065 |
++ goto bail_unlock_alloc; |
1066 |
+ } |
1067 |
+ status = __dquot_transfer(inode, transfer_to); |
1068 |
+ if (status < 0) |
1069 |
+ goto bail_commit; |
1070 |
+ } else { |
1071 |
++ down_write(&OCFS2_I(inode)->ip_alloc_sem); |
1072 |
+ handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS); |
1073 |
+ if (IS_ERR(handle)) { |
1074 |
+ status = PTR_ERR(handle); |
1075 |
+ mlog_errno(status); |
1076 |
+- goto bail_unlock; |
1077 |
++ goto bail_unlock_alloc; |
1078 |
+ } |
1079 |
+ } |
1080 |
+ |
1081 |
+@@ -1278,6 +1280,8 @@ int ocfs2_setattr(struct dentry *dentry, struct iattr *attr) |
1082 |
+ |
1083 |
+ bail_commit: |
1084 |
+ ocfs2_commit_trans(osb, handle); |
1085 |
++bail_unlock_alloc: |
1086 |
++ up_write(&OCFS2_I(inode)->ip_alloc_sem); |
1087 |
+ bail_unlock: |
1088 |
+ if (status && inode_locked) { |
1089 |
+ ocfs2_inode_unlock_tracker(inode, 1, &oh, had_lock); |
1090 |
+diff --git a/include/linux/mlx5/mlx5_ifc.h b/include/linux/mlx5/mlx5_ifc.h |
1091 |
+index 6ffa181598e61..c4b8602ea6f57 100644 |
1092 |
+--- a/include/linux/mlx5/mlx5_ifc.h |
1093 |
++++ b/include/linux/mlx5/mlx5_ifc.h |
1094 |
+@@ -324,11 +324,11 @@ struct mlx5_ifc_flow_table_prop_layout_bits { |
1095 |
+ u8 reserved_at_60[0x18]; |
1096 |
+ u8 log_max_ft_num[0x8]; |
1097 |
+ |
1098 |
+- u8 reserved_at_80[0x18]; |
1099 |
++ u8 reserved_at_80[0x10]; |
1100 |
++ u8 log_max_flow_counter[0x8]; |
1101 |
+ u8 log_max_destination[0x8]; |
1102 |
+ |
1103 |
+- u8 log_max_flow_counter[0x8]; |
1104 |
+- u8 reserved_at_a8[0x10]; |
1105 |
++ u8 reserved_at_a0[0x18]; |
1106 |
+ u8 log_max_flow[0x8]; |
1107 |
+ |
1108 |
+ u8 reserved_at_c0[0x40]; |
1109 |
+diff --git a/include/linux/virtio_net.h b/include/linux/virtio_net.h |
1110 |
+index 3e26e5dd9546a..48afea1b8b4e5 100644 |
1111 |
+--- a/include/linux/virtio_net.h |
1112 |
++++ b/include/linux/virtio_net.h |
1113 |
+@@ -62,6 +62,8 @@ static inline int virtio_net_hdr_to_skb(struct sk_buff *skb, |
1114 |
+ return -EINVAL; |
1115 |
+ } |
1116 |
+ |
1117 |
++ skb_reset_mac_header(skb); |
1118 |
++ |
1119 |
+ if (hdr->flags & VIRTIO_NET_HDR_F_NEEDS_CSUM) { |
1120 |
+ u16 start = __virtio16_to_cpu(little_endian, hdr->csum_start); |
1121 |
+ u16 off = __virtio16_to_cpu(little_endian, hdr->csum_offset); |
1122 |
+diff --git a/include/net/red.h b/include/net/red.h |
1123 |
+index 8fe55b8b2fb81..ff07a7cedf685 100644 |
1124 |
+--- a/include/net/red.h |
1125 |
++++ b/include/net/red.h |
1126 |
+@@ -171,9 +171,9 @@ static inline void red_set_vars(struct red_vars *v) |
1127 |
+ static inline bool red_check_params(u32 qth_min, u32 qth_max, u8 Wlog, |
1128 |
+ u8 Scell_log, u8 *stab) |
1129 |
+ { |
1130 |
+- if (fls(qth_min) + Wlog > 32) |
1131 |
++ if (fls(qth_min) + Wlog >= 32) |
1132 |
+ return false; |
1133 |
+- if (fls(qth_max) + Wlog > 32) |
1134 |
++ if (fls(qth_max) + Wlog >= 32) |
1135 |
+ return false; |
1136 |
+ if (Scell_log >= 32) |
1137 |
+ return false; |
1138 |
+diff --git a/include/uapi/linux/ncsi.h b/include/uapi/linux/ncsi.h |
1139 |
+new file mode 100644 |
1140 |
+index 0000000000000..4c292ecbb748f |
1141 |
+--- /dev/null |
1142 |
++++ b/include/uapi/linux/ncsi.h |
1143 |
+@@ -0,0 +1,115 @@ |
1144 |
++/* |
1145 |
++ * Copyright Samuel Mendoza-Jonas, IBM Corporation 2018. |
1146 |
++ * |
1147 |
++ * This program is free software; you can redistribute it and/or modify |
1148 |
++ * it under the terms of the GNU General Public License as published by |
1149 |
++ * the Free Software Foundation; either version 2 of the License, or |
1150 |
++ * (at your option) any later version. |
1151 |
++ */ |
1152 |
++ |
1153 |
++#ifndef __UAPI_NCSI_NETLINK_H__ |
1154 |
++#define __UAPI_NCSI_NETLINK_H__ |
1155 |
++ |
1156 |
++/** |
1157 |
++ * enum ncsi_nl_commands - supported NCSI commands |
1158 |
++ * |
1159 |
++ * @NCSI_CMD_UNSPEC: unspecified command to catch errors |
1160 |
++ * @NCSI_CMD_PKG_INFO: list package and channel attributes. Requires |
1161 |
++ * NCSI_ATTR_IFINDEX. If NCSI_ATTR_PACKAGE_ID is specified returns the |
1162 |
++ * specific package and its channels - otherwise a dump request returns |
1163 |
++ * all packages and their associated channels. |
1164 |
++ * @NCSI_CMD_SET_INTERFACE: set preferred package and channel combination. |
1165 |
++ * Requires NCSI_ATTR_IFINDEX and the preferred NCSI_ATTR_PACKAGE_ID and |
1166 |
++ * optionally the preferred NCSI_ATTR_CHANNEL_ID. |
1167 |
++ * @NCSI_CMD_CLEAR_INTERFACE: clear any preferred package/channel combination. |
1168 |
++ * Requires NCSI_ATTR_IFINDEX. |
1169 |
++ * @NCSI_CMD_MAX: highest command number |
1170 |
++ */ |
1171 |
++enum ncsi_nl_commands { |
1172 |
++ NCSI_CMD_UNSPEC, |
1173 |
++ NCSI_CMD_PKG_INFO, |
1174 |
++ NCSI_CMD_SET_INTERFACE, |
1175 |
++ NCSI_CMD_CLEAR_INTERFACE, |
1176 |
++ |
1177 |
++ __NCSI_CMD_AFTER_LAST, |
1178 |
++ NCSI_CMD_MAX = __NCSI_CMD_AFTER_LAST - 1 |
1179 |
++}; |
1180 |
++ |
1181 |
++/** |
1182 |
++ * enum ncsi_nl_attrs - General NCSI netlink attributes |
1183 |
++ * |
1184 |
++ * @NCSI_ATTR_UNSPEC: unspecified attributes to catch errors |
1185 |
++ * @NCSI_ATTR_IFINDEX: ifindex of network device using NCSI |
1186 |
++ * @NCSI_ATTR_PACKAGE_LIST: nested array of NCSI_PKG_ATTR attributes |
1187 |
++ * @NCSI_ATTR_PACKAGE_ID: package ID |
1188 |
++ * @NCSI_ATTR_CHANNEL_ID: channel ID |
1189 |
++ * @NCSI_ATTR_MAX: highest attribute number |
1190 |
++ */ |
1191 |
++enum ncsi_nl_attrs { |
1192 |
++ NCSI_ATTR_UNSPEC, |
1193 |
++ NCSI_ATTR_IFINDEX, |
1194 |
++ NCSI_ATTR_PACKAGE_LIST, |
1195 |
++ NCSI_ATTR_PACKAGE_ID, |
1196 |
++ NCSI_ATTR_CHANNEL_ID, |
1197 |
++ |
1198 |
++ __NCSI_ATTR_AFTER_LAST, |
1199 |
++ NCSI_ATTR_MAX = __NCSI_ATTR_AFTER_LAST - 1 |
1200 |
++}; |
1201 |
++ |
1202 |
++/** |
1203 |
++ * enum ncsi_nl_pkg_attrs - NCSI netlink package-specific attributes |
1204 |
++ * |
1205 |
++ * @NCSI_PKG_ATTR_UNSPEC: unspecified attributes to catch errors |
1206 |
++ * @NCSI_PKG_ATTR: nested array of package attributes |
1207 |
++ * @NCSI_PKG_ATTR_ID: package ID |
1208 |
++ * @NCSI_PKG_ATTR_FORCED: flag signifying a package has been set as preferred |
1209 |
++ * @NCSI_PKG_ATTR_CHANNEL_LIST: nested array of NCSI_CHANNEL_ATTR attributes |
1210 |
++ * @NCSI_PKG_ATTR_MAX: highest attribute number |
1211 |
++ */ |
1212 |
++enum ncsi_nl_pkg_attrs { |
1213 |
++ NCSI_PKG_ATTR_UNSPEC, |
1214 |
++ NCSI_PKG_ATTR, |
1215 |
++ NCSI_PKG_ATTR_ID, |
1216 |
++ NCSI_PKG_ATTR_FORCED, |
1217 |
++ NCSI_PKG_ATTR_CHANNEL_LIST, |
1218 |
++ |
1219 |
++ __NCSI_PKG_ATTR_AFTER_LAST, |
1220 |
++ NCSI_PKG_ATTR_MAX = __NCSI_PKG_ATTR_AFTER_LAST - 1 |
1221 |
++}; |
1222 |
++ |
1223 |
++/** |
1224 |
++ * enum ncsi_nl_channel_attrs - NCSI netlink channel-specific attributes |
1225 |
++ * |
1226 |
++ * @NCSI_CHANNEL_ATTR_UNSPEC: unspecified attributes to catch errors |
1227 |
++ * @NCSI_CHANNEL_ATTR: nested array of channel attributes |
1228 |
++ * @NCSI_CHANNEL_ATTR_ID: channel ID |
1229 |
++ * @NCSI_CHANNEL_ATTR_VERSION_MAJOR: channel major version number |
1230 |
++ * @NCSI_CHANNEL_ATTR_VERSION_MINOR: channel minor version number |
1231 |
++ * @NCSI_CHANNEL_ATTR_VERSION_STR: channel version string |
1232 |
++ * @NCSI_CHANNEL_ATTR_LINK_STATE: channel link state flags |
1233 |
++ * @NCSI_CHANNEL_ATTR_ACTIVE: channels with this flag are in |
1234 |
++ * NCSI_CHANNEL_ACTIVE state |
1235 |
++ * @NCSI_CHANNEL_ATTR_FORCED: flag signifying a channel has been set as |
1236 |
++ * preferred |
1237 |
++ * @NCSI_CHANNEL_ATTR_VLAN_LIST: nested array of NCSI_CHANNEL_ATTR_VLAN_IDs |
1238 |
++ * @NCSI_CHANNEL_ATTR_VLAN_ID: VLAN ID being filtered on this channel |
1239 |
++ * @NCSI_CHANNEL_ATTR_MAX: highest attribute number |
1240 |
++ */ |
1241 |
++enum ncsi_nl_channel_attrs { |
1242 |
++ NCSI_CHANNEL_ATTR_UNSPEC, |
1243 |
++ NCSI_CHANNEL_ATTR, |
1244 |
++ NCSI_CHANNEL_ATTR_ID, |
1245 |
++ NCSI_CHANNEL_ATTR_VERSION_MAJOR, |
1246 |
++ NCSI_CHANNEL_ATTR_VERSION_MINOR, |
1247 |
++ NCSI_CHANNEL_ATTR_VERSION_STR, |
1248 |
++ NCSI_CHANNEL_ATTR_LINK_STATE, |
1249 |
++ NCSI_CHANNEL_ATTR_ACTIVE, |
1250 |
++ NCSI_CHANNEL_ATTR_FORCED, |
1251 |
++ NCSI_CHANNEL_ATTR_VLAN_LIST, |
1252 |
++ NCSI_CHANNEL_ATTR_VLAN_ID, |
1253 |
++ |
1254 |
++ __NCSI_CHANNEL_ATTR_AFTER_LAST, |
1255 |
++ NCSI_CHANNEL_ATTR_MAX = __NCSI_CHANNEL_ATTR_AFTER_LAST - 1 |
1256 |
++}; |
1257 |
++ |
1258 |
++#endif /* __UAPI_NCSI_NETLINK_H__ */ |
1259 |
+diff --git a/kernel/workqueue.c b/kernel/workqueue.c |
1260 |
+index 79fcec674485f..bc32ed4a4cf32 100644 |
1261 |
+--- a/kernel/workqueue.c |
1262 |
++++ b/kernel/workqueue.c |
1263 |
+@@ -1379,7 +1379,6 @@ static void __queue_work(int cpu, struct workqueue_struct *wq, |
1264 |
+ */ |
1265 |
+ WARN_ON_ONCE(!irqs_disabled()); |
1266 |
+ |
1267 |
+- debug_work_activate(work); |
1268 |
+ |
1269 |
+ /* if draining, only works from the same workqueue are allowed */ |
1270 |
+ if (unlikely(wq->flags & __WQ_DRAINING) && |
1271 |
+@@ -1462,6 +1461,7 @@ retry: |
1272 |
+ worklist = &pwq->delayed_works; |
1273 |
+ } |
1274 |
+ |
1275 |
++ debug_work_activate(work); |
1276 |
+ insert_work(pwq, work, worklist, work_flags); |
1277 |
+ |
1278 |
+ spin_unlock(&pwq->pool->lock); |
1279 |
+diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c |
1280 |
+index dbc516824175b..9cef38f6cb4de 100644 |
1281 |
+--- a/net/batman-adv/translation-table.c |
1282 |
++++ b/net/batman-adv/translation-table.c |
1283 |
+@@ -902,6 +902,7 @@ batadv_tt_prepare_tvlv_global_data(struct batadv_orig_node *orig_node, |
1284 |
+ hlist_for_each_entry_rcu(vlan, &orig_node->vlan_list, list) { |
1285 |
+ tt_vlan->vid = htons(vlan->vid); |
1286 |
+ tt_vlan->crc = htonl(vlan->tt.crc); |
1287 |
++ tt_vlan->reserved = 0; |
1288 |
+ |
1289 |
+ tt_vlan++; |
1290 |
+ } |
1291 |
+@@ -985,6 +986,7 @@ batadv_tt_prepare_tvlv_local_data(struct batadv_priv *bat_priv, |
1292 |
+ |
1293 |
+ tt_vlan->vid = htons(vlan->vid); |
1294 |
+ tt_vlan->crc = htonl(vlan->tt.crc); |
1295 |
++ tt_vlan->reserved = 0; |
1296 |
+ |
1297 |
+ tt_vlan++; |
1298 |
+ } |
1299 |
+diff --git a/net/ieee802154/nl-mac.c b/net/ieee802154/nl-mac.c |
1300 |
+index d3cbb32587187..c0930b9fe848b 100644 |
1301 |
+--- a/net/ieee802154/nl-mac.c |
1302 |
++++ b/net/ieee802154/nl-mac.c |
1303 |
+@@ -559,9 +559,7 @@ ieee802154_llsec_parse_key_id(struct genl_info *info, |
1304 |
+ desc->mode = nla_get_u8(info->attrs[IEEE802154_ATTR_LLSEC_KEY_MODE]); |
1305 |
+ |
1306 |
+ if (desc->mode == IEEE802154_SCF_KEY_IMPLICIT) { |
1307 |
+- if (!info->attrs[IEEE802154_ATTR_PAN_ID] && |
1308 |
+- !(info->attrs[IEEE802154_ATTR_SHORT_ADDR] || |
1309 |
+- info->attrs[IEEE802154_ATTR_HW_ADDR])) |
1310 |
++ if (!info->attrs[IEEE802154_ATTR_PAN_ID]) |
1311 |
+ return -EINVAL; |
1312 |
+ |
1313 |
+ desc->device_addr.pan_id = nla_get_shortaddr(info->attrs[IEEE802154_ATTR_PAN_ID]); |
1314 |
+@@ -570,6 +568,9 @@ ieee802154_llsec_parse_key_id(struct genl_info *info, |
1315 |
+ desc->device_addr.mode = IEEE802154_ADDR_SHORT; |
1316 |
+ desc->device_addr.short_addr = nla_get_shortaddr(info->attrs[IEEE802154_ATTR_SHORT_ADDR]); |
1317 |
+ } else { |
1318 |
++ if (!info->attrs[IEEE802154_ATTR_HW_ADDR]) |
1319 |
++ return -EINVAL; |
1320 |
++ |
1321 |
+ desc->device_addr.mode = IEEE802154_ADDR_LONG; |
1322 |
+ desc->device_addr.extended_addr = nla_get_hwaddr(info->attrs[IEEE802154_ATTR_HW_ADDR]); |
1323 |
+ } |
1324 |
+diff --git a/net/ieee802154/nl802154.c b/net/ieee802154/nl802154.c |
1325 |
+index 99f6c254ea777..b10b297e76b78 100644 |
1326 |
+--- a/net/ieee802154/nl802154.c |
1327 |
++++ b/net/ieee802154/nl802154.c |
1328 |
+@@ -836,8 +836,13 @@ nl802154_send_iface(struct sk_buff *msg, u32 portid, u32 seq, int flags, |
1329 |
+ goto nla_put_failure; |
1330 |
+ |
1331 |
+ #ifdef CONFIG_IEEE802154_NL802154_EXPERIMENTAL |
1332 |
++ if (wpan_dev->iftype == NL802154_IFTYPE_MONITOR) |
1333 |
++ goto out; |
1334 |
++ |
1335 |
+ if (nl802154_get_llsec_params(msg, rdev, wpan_dev) < 0) |
1336 |
+ goto nla_put_failure; |
1337 |
++ |
1338 |
++out: |
1339 |
+ #endif /* CONFIG_IEEE802154_NL802154_EXPERIMENTAL */ |
1340 |
+ |
1341 |
+ genlmsg_end(msg, hdr); |
1342 |
+@@ -1402,6 +1407,9 @@ static int nl802154_set_llsec_params(struct sk_buff *skb, |
1343 |
+ u32 changed = 0; |
1344 |
+ int ret; |
1345 |
+ |
1346 |
++ if (wpan_dev->iftype == NL802154_IFTYPE_MONITOR) |
1347 |
++ return -EOPNOTSUPP; |
1348 |
++ |
1349 |
+ if (info->attrs[NL802154_ATTR_SEC_ENABLED]) { |
1350 |
+ u8 enabled; |
1351 |
+ |
1352 |
+@@ -1562,7 +1570,8 @@ static int nl802154_add_llsec_key(struct sk_buff *skb, struct genl_info *info) |
1353 |
+ struct ieee802154_llsec_key_id id = { }; |
1354 |
+ u32 commands[NL802154_CMD_FRAME_NR_IDS / 32] = { }; |
1355 |
+ |
1356 |
+- if (nla_parse_nested(attrs, NL802154_KEY_ATTR_MAX, |
1357 |
++ if (!info->attrs[NL802154_ATTR_SEC_KEY] || |
1358 |
++ nla_parse_nested(attrs, NL802154_KEY_ATTR_MAX, |
1359 |
+ info->attrs[NL802154_ATTR_SEC_KEY], |
1360 |
+ nl802154_key_policy, info->extack)) |
1361 |
+ return -EINVAL; |
1362 |
+@@ -1612,7 +1621,8 @@ static int nl802154_del_llsec_key(struct sk_buff *skb, struct genl_info *info) |
1363 |
+ struct nlattr *attrs[NL802154_KEY_ATTR_MAX + 1]; |
1364 |
+ struct ieee802154_llsec_key_id id; |
1365 |
+ |
1366 |
+- if (nla_parse_nested(attrs, NL802154_KEY_ATTR_MAX, |
1367 |
++ if (!info->attrs[NL802154_ATTR_SEC_KEY] || |
1368 |
++ nla_parse_nested(attrs, NL802154_KEY_ATTR_MAX, |
1369 |
+ info->attrs[NL802154_ATTR_SEC_KEY], |
1370 |
+ nl802154_key_policy, info->extack)) |
1371 |
+ return -EINVAL; |
1372 |
+@@ -1780,7 +1790,8 @@ static int nl802154_del_llsec_dev(struct sk_buff *skb, struct genl_info *info) |
1373 |
+ struct nlattr *attrs[NL802154_DEV_ATTR_MAX + 1]; |
1374 |
+ __le64 extended_addr; |
1375 |
+ |
1376 |
+- if (nla_parse_nested(attrs, NL802154_DEV_ATTR_MAX, |
1377 |
++ if (!info->attrs[NL802154_ATTR_SEC_DEVICE] || |
1378 |
++ nla_parse_nested(attrs, NL802154_DEV_ATTR_MAX, |
1379 |
+ info->attrs[NL802154_ATTR_SEC_DEVICE], |
1380 |
+ nl802154_dev_policy, info->extack)) |
1381 |
+ return -EINVAL; |
1382 |
+@@ -1940,7 +1951,8 @@ static int nl802154_del_llsec_devkey(struct sk_buff *skb, struct genl_info *info |
1383 |
+ struct ieee802154_llsec_device_key key; |
1384 |
+ __le64 extended_addr; |
1385 |
+ |
1386 |
+- if (nla_parse_nested(attrs, NL802154_DEVKEY_ATTR_MAX, |
1387 |
++ if (!info->attrs[NL802154_ATTR_SEC_DEVKEY] || |
1388 |
++ nla_parse_nested(attrs, NL802154_DEVKEY_ATTR_MAX, |
1389 |
+ info->attrs[NL802154_ATTR_SEC_DEVKEY], |
1390 |
+ nl802154_devkey_policy, info->extack)) |
1391 |
+ return -EINVAL; |
1392 |
+@@ -2115,6 +2127,9 @@ static int nl802154_del_llsec_seclevel(struct sk_buff *skb, |
1393 |
+ struct wpan_dev *wpan_dev = dev->ieee802154_ptr; |
1394 |
+ struct ieee802154_llsec_seclevel sl; |
1395 |
+ |
1396 |
++ if (wpan_dev->iftype == NL802154_IFTYPE_MONITOR) |
1397 |
++ return -EOPNOTSUPP; |
1398 |
++ |
1399 |
+ if (!info->attrs[NL802154_ATTR_SEC_LEVEL] || |
1400 |
+ llsec_parse_seclevel(info->attrs[NL802154_ATTR_SEC_LEVEL], |
1401 |
+ &sl) < 0) |
1402 |
+diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c |
1403 |
+index 6dd727e0a72f6..13a46066546db 100644 |
1404 |
+--- a/net/ipv4/netfilter/arp_tables.c |
1405 |
++++ b/net/ipv4/netfilter/arp_tables.c |
1406 |
+@@ -1196,6 +1196,8 @@ static int translate_compat_table(struct net *net, |
1407 |
+ if (!newinfo) |
1408 |
+ goto out_unlock; |
1409 |
+ |
1410 |
++ memset(newinfo->entries, 0, size); |
1411 |
++ |
1412 |
+ newinfo->number = compatr->num_entries; |
1413 |
+ for (i = 0; i < NF_ARP_NUMHOOKS; i++) { |
1414 |
+ newinfo->hook_entry[i] = compatr->hook_entry[i]; |
1415 |
+diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c |
1416 |
+index 0d1a2cda1bfb1..a4039ac65b546 100644 |
1417 |
+--- a/net/ipv4/netfilter/ip_tables.c |
1418 |
++++ b/net/ipv4/netfilter/ip_tables.c |
1419 |
+@@ -1432,6 +1432,8 @@ translate_compat_table(struct net *net, |
1420 |
+ if (!newinfo) |
1421 |
+ goto out_unlock; |
1422 |
+ |
1423 |
++ memset(newinfo->entries, 0, size); |
1424 |
++ |
1425 |
+ newinfo->number = compatr->num_entries; |
1426 |
+ for (i = 0; i < NF_INET_NUMHOOKS; i++) { |
1427 |
+ newinfo->hook_entry[i] = compatr->hook_entry[i]; |
1428 |
+diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c |
1429 |
+index 90f5bf2502a73..d0d5e43727307 100644 |
1430 |
+--- a/net/ipv6/netfilter/ip6_tables.c |
1431 |
++++ b/net/ipv6/netfilter/ip6_tables.c |
1432 |
+@@ -1449,6 +1449,8 @@ translate_compat_table(struct net *net, |
1433 |
+ if (!newinfo) |
1434 |
+ goto out_unlock; |
1435 |
+ |
1436 |
++ memset(newinfo->entries, 0, size); |
1437 |
++ |
1438 |
+ newinfo->number = compatr->num_entries; |
1439 |
+ for (i = 0; i < NF_INET_NUMHOOKS; i++) { |
1440 |
+ newinfo->hook_entry[i] = compatr->hook_entry[i]; |
1441 |
+diff --git a/net/ipv6/route.c b/net/ipv6/route.c |
1442 |
+index ddcaca5979b1d..76e10019a0e9f 100644 |
1443 |
+--- a/net/ipv6/route.c |
1444 |
++++ b/net/ipv6/route.c |
1445 |
+@@ -3283,9 +3283,11 @@ static int ip6_route_multipath_add(struct fib6_config *cfg, |
1446 |
+ * nexthops have been replaced by first new, the rest should |
1447 |
+ * be added to it. |
1448 |
+ */ |
1449 |
+- cfg->fc_nlinfo.nlh->nlmsg_flags &= ~(NLM_F_EXCL | |
1450 |
+- NLM_F_REPLACE); |
1451 |
+- cfg->fc_nlinfo.nlh->nlmsg_flags |= NLM_F_CREATE; |
1452 |
++ if (cfg->fc_nlinfo.nlh) { |
1453 |
++ cfg->fc_nlinfo.nlh->nlmsg_flags &= ~(NLM_F_EXCL | |
1454 |
++ NLM_F_REPLACE); |
1455 |
++ cfg->fc_nlinfo.nlh->nlmsg_flags |= NLM_F_CREATE; |
1456 |
++ } |
1457 |
+ nhn++; |
1458 |
+ } |
1459 |
+ |
1460 |
+diff --git a/net/mac802154/llsec.c b/net/mac802154/llsec.c |
1461 |
+index 1e1c9b20bab7f..ed1b9876d5458 100644 |
1462 |
+--- a/net/mac802154/llsec.c |
1463 |
++++ b/net/mac802154/llsec.c |
1464 |
+@@ -160,7 +160,7 @@ err_tfm0: |
1465 |
+ crypto_free_skcipher(key->tfm0); |
1466 |
+ err_tfm: |
1467 |
+ for (i = 0; i < ARRAY_SIZE(key->tfm); i++) |
1468 |
+- if (key->tfm[i]) |
1469 |
++ if (!IS_ERR_OR_NULL(key->tfm[i])) |
1470 |
+ crypto_free_aead(key->tfm[i]); |
1471 |
+ |
1472 |
+ kzfree(key); |
1473 |
+diff --git a/net/ncsi/Makefile b/net/ncsi/Makefile |
1474 |
+index dd12b564f2e7e..436ef68331f2b 100644 |
1475 |
+--- a/net/ncsi/Makefile |
1476 |
++++ b/net/ncsi/Makefile |
1477 |
+@@ -1,4 +1,4 @@ |
1478 |
+ # |
1479 |
+ # Makefile for NCSI API |
1480 |
+ # |
1481 |
+-obj-$(CONFIG_NET_NCSI) += ncsi-cmd.o ncsi-rsp.o ncsi-aen.o ncsi-manage.o |
1482 |
++obj-$(CONFIG_NET_NCSI) += ncsi-cmd.o ncsi-rsp.o ncsi-aen.o ncsi-manage.o ncsi-netlink.o |
1483 |
+diff --git a/net/ncsi/internal.h b/net/ncsi/internal.h |
1484 |
+index d30f7bd741d06..8055e3965cef2 100644 |
1485 |
+--- a/net/ncsi/internal.h |
1486 |
++++ b/net/ncsi/internal.h |
1487 |
+@@ -68,15 +68,6 @@ enum { |
1488 |
+ NCSI_MODE_MAX |
1489 |
+ }; |
1490 |
+ |
1491 |
+-enum { |
1492 |
+- NCSI_FILTER_BASE = 0, |
1493 |
+- NCSI_FILTER_VLAN = 0, |
1494 |
+- NCSI_FILTER_UC, |
1495 |
+- NCSI_FILTER_MC, |
1496 |
+- NCSI_FILTER_MIXED, |
1497 |
+- NCSI_FILTER_MAX |
1498 |
+-}; |
1499 |
+- |
1500 |
+ struct ncsi_channel_version { |
1501 |
+ u32 version; /* Supported BCD encoded NCSI version */ |
1502 |
+ u32 alpha2; /* Supported BCD encoded NCSI version */ |
1503 |
+@@ -98,11 +89,18 @@ struct ncsi_channel_mode { |
1504 |
+ u32 data[8]; /* Data entries */ |
1505 |
+ }; |
1506 |
+ |
1507 |
+-struct ncsi_channel_filter { |
1508 |
+- u32 index; /* Index of channel filters */ |
1509 |
+- u32 total; /* Total entries in the filter table */ |
1510 |
+- u64 bitmap; /* Bitmap of valid entries */ |
1511 |
+- u32 data[]; /* Data for the valid entries */ |
1512 |
++struct ncsi_channel_mac_filter { |
1513 |
++ u8 n_uc; |
1514 |
++ u8 n_mc; |
1515 |
++ u8 n_mixed; |
1516 |
++ u64 bitmap; |
1517 |
++ unsigned char *addrs; |
1518 |
++}; |
1519 |
++ |
1520 |
++struct ncsi_channel_vlan_filter { |
1521 |
++ u8 n_vids; |
1522 |
++ u64 bitmap; |
1523 |
++ u16 *vids; |
1524 |
+ }; |
1525 |
+ |
1526 |
+ struct ncsi_channel_stats { |
1527 |
+@@ -186,7 +184,9 @@ struct ncsi_channel { |
1528 |
+ struct ncsi_channel_version version; |
1529 |
+ struct ncsi_channel_cap caps[NCSI_CAP_MAX]; |
1530 |
+ struct ncsi_channel_mode modes[NCSI_MODE_MAX]; |
1531 |
+- struct ncsi_channel_filter *filters[NCSI_FILTER_MAX]; |
1532 |
++ /* Filtering Settings */ |
1533 |
++ struct ncsi_channel_mac_filter mac_filter; |
1534 |
++ struct ncsi_channel_vlan_filter vlan_filter; |
1535 |
+ struct ncsi_channel_stats stats; |
1536 |
+ struct { |
1537 |
+ struct timer_list timer; |
1538 |
+@@ -276,6 +276,8 @@ struct ncsi_dev_priv { |
1539 |
+ unsigned int package_num; /* Number of packages */ |
1540 |
+ struct list_head packages; /* List of packages */ |
1541 |
+ struct ncsi_channel *hot_channel; /* Channel was ever active */ |
1542 |
++ struct ncsi_package *force_package; /* Force a specific package */ |
1543 |
++ struct ncsi_channel *force_channel; /* Force a specific channel */ |
1544 |
+ struct ncsi_request requests[256]; /* Request table */ |
1545 |
+ unsigned int request_id; /* Last used request ID */ |
1546 |
+ #define NCSI_REQ_START_IDX 1 |
1547 |
+@@ -318,9 +320,6 @@ extern spinlock_t ncsi_dev_lock; |
1548 |
+ list_for_each_entry_rcu(nc, &np->channels, node) |
1549 |
+ |
1550 |
+ /* Resources */ |
1551 |
+-int ncsi_find_filter(struct ncsi_channel *nc, int table, void *data); |
1552 |
+-int ncsi_add_filter(struct ncsi_channel *nc, int table, void *data); |
1553 |
+-int ncsi_remove_filter(struct ncsi_channel *nc, int table, int index); |
1554 |
+ void ncsi_start_channel_monitor(struct ncsi_channel *nc); |
1555 |
+ void ncsi_stop_channel_monitor(struct ncsi_channel *nc); |
1556 |
+ struct ncsi_channel *ncsi_find_channel(struct ncsi_package *np, |
1557 |
+diff --git a/net/ncsi/ncsi-aen.c b/net/ncsi/ncsi-aen.c |
1558 |
+index f135938bf781e..67e708e98ccf0 100644 |
1559 |
+--- a/net/ncsi/ncsi-aen.c |
1560 |
++++ b/net/ncsi/ncsi-aen.c |
1561 |
+@@ -73,6 +73,9 @@ static int ncsi_aen_handler_lsc(struct ncsi_dev_priv *ndp, |
1562 |
+ ncm->data[2] = data; |
1563 |
+ ncm->data[4] = ntohl(lsc->oem_status); |
1564 |
+ |
1565 |
++ netdev_info(ndp->ndev.dev, "NCSI: LSC AEN - channel %u state %s\n", |
1566 |
++ nc->id, data & 0x1 ? "up" : "down"); |
1567 |
++ |
1568 |
+ chained = !list_empty(&nc->link); |
1569 |
+ state = nc->state; |
1570 |
+ spin_unlock_irqrestore(&nc->lock, flags); |
1571 |
+@@ -145,6 +148,8 @@ static int ncsi_aen_handler_hncdsc(struct ncsi_dev_priv *ndp, |
1572 |
+ ncm = &nc->modes[NCSI_MODE_LINK]; |
1573 |
+ hncdsc = (struct ncsi_aen_hncdsc_pkt *)h; |
1574 |
+ ncm->data[3] = ntohl(hncdsc->status); |
1575 |
++ netdev_info(ndp->ndev.dev, "NCSI: HNCDSC AEN - channel %u state %s\n", |
1576 |
++ nc->id, ncm->data[3] & 0x3 ? "up" : "down"); |
1577 |
+ if (!list_empty(&nc->link) || |
1578 |
+ nc->state != NCSI_CHANNEL_ACTIVE) { |
1579 |
+ spin_unlock_irqrestore(&nc->lock, flags); |
1580 |
+@@ -212,10 +217,18 @@ int ncsi_aen_handler(struct ncsi_dev_priv *ndp, struct sk_buff *skb) |
1581 |
+ } |
1582 |
+ |
1583 |
+ ret = ncsi_validate_aen_pkt(h, nah->payload); |
1584 |
+- if (ret) |
1585 |
++ if (ret) { |
1586 |
++ netdev_warn(ndp->ndev.dev, |
1587 |
++ "NCSI: 'bad' packet ignored for AEN type 0x%x\n", |
1588 |
++ h->type); |
1589 |
+ goto out; |
1590 |
++ } |
1591 |
+ |
1592 |
+ ret = nah->handler(ndp, h); |
1593 |
++ if (ret) |
1594 |
++ netdev_err(ndp->ndev.dev, |
1595 |
++ "NCSI: Handler for AEN type 0x%x returned %d\n", |
1596 |
++ h->type, ret); |
1597 |
+ out: |
1598 |
+ consume_skb(skb); |
1599 |
+ return ret; |
1600 |
+diff --git a/net/ncsi/ncsi-manage.c b/net/ncsi/ncsi-manage.c |
1601 |
+index 28c42b22b7489..dbe8aec6c57bb 100644 |
1602 |
+--- a/net/ncsi/ncsi-manage.c |
1603 |
++++ b/net/ncsi/ncsi-manage.c |
1604 |
+@@ -12,7 +12,6 @@ |
1605 |
+ #include <linux/init.h> |
1606 |
+ #include <linux/netdevice.h> |
1607 |
+ #include <linux/skbuff.h> |
1608 |
+-#include <linux/netlink.h> |
1609 |
+ |
1610 |
+ #include <net/ncsi.h> |
1611 |
+ #include <net/net_namespace.h> |
1612 |
+@@ -23,129 +22,11 @@ |
1613 |
+ |
1614 |
+ #include "internal.h" |
1615 |
+ #include "ncsi-pkt.h" |
1616 |
++#include "ncsi-netlink.h" |
1617 |
+ |
1618 |
+ LIST_HEAD(ncsi_dev_list); |
1619 |
+ DEFINE_SPINLOCK(ncsi_dev_lock); |
1620 |
+ |
1621 |
+-static inline int ncsi_filter_size(int table) |
1622 |
+-{ |
1623 |
+- int sizes[] = { 2, 6, 6, 6 }; |
1624 |
+- |
1625 |
+- BUILD_BUG_ON(ARRAY_SIZE(sizes) != NCSI_FILTER_MAX); |
1626 |
+- if (table < NCSI_FILTER_BASE || table >= NCSI_FILTER_MAX) |
1627 |
+- return -EINVAL; |
1628 |
+- |
1629 |
+- return sizes[table]; |
1630 |
+-} |
1631 |
+- |
1632 |
+-u32 *ncsi_get_filter(struct ncsi_channel *nc, int table, int index) |
1633 |
+-{ |
1634 |
+- struct ncsi_channel_filter *ncf; |
1635 |
+- int size; |
1636 |
+- |
1637 |
+- ncf = nc->filters[table]; |
1638 |
+- if (!ncf) |
1639 |
+- return NULL; |
1640 |
+- |
1641 |
+- size = ncsi_filter_size(table); |
1642 |
+- if (size < 0) |
1643 |
+- return NULL; |
1644 |
+- |
1645 |
+- return ncf->data + size * index; |
1646 |
+-} |
1647 |
+- |
1648 |
+-/* Find the first active filter in a filter table that matches the given |
1649 |
+- * data parameter. If data is NULL, this returns the first active filter. |
1650 |
+- */ |
1651 |
+-int ncsi_find_filter(struct ncsi_channel *nc, int table, void *data) |
1652 |
+-{ |
1653 |
+- struct ncsi_channel_filter *ncf; |
1654 |
+- void *bitmap; |
1655 |
+- int index, size; |
1656 |
+- unsigned long flags; |
1657 |
+- |
1658 |
+- ncf = nc->filters[table]; |
1659 |
+- if (!ncf) |
1660 |
+- return -ENXIO; |
1661 |
+- |
1662 |
+- size = ncsi_filter_size(table); |
1663 |
+- if (size < 0) |
1664 |
+- return size; |
1665 |
+- |
1666 |
+- spin_lock_irqsave(&nc->lock, flags); |
1667 |
+- bitmap = (void *)&ncf->bitmap; |
1668 |
+- index = -1; |
1669 |
+- while ((index = find_next_bit(bitmap, ncf->total, index + 1)) |
1670 |
+- < ncf->total) { |
1671 |
+- if (!data || !memcmp(ncf->data + size * index, data, size)) { |
1672 |
+- spin_unlock_irqrestore(&nc->lock, flags); |
1673 |
+- return index; |
1674 |
+- } |
1675 |
+- } |
1676 |
+- spin_unlock_irqrestore(&nc->lock, flags); |
1677 |
+- |
1678 |
+- return -ENOENT; |
1679 |
+-} |
1680 |
+- |
1681 |
+-int ncsi_add_filter(struct ncsi_channel *nc, int table, void *data) |
1682 |
+-{ |
1683 |
+- struct ncsi_channel_filter *ncf; |
1684 |
+- int index, size; |
1685 |
+- void *bitmap; |
1686 |
+- unsigned long flags; |
1687 |
+- |
1688 |
+- size = ncsi_filter_size(table); |
1689 |
+- if (size < 0) |
1690 |
+- return size; |
1691 |
+- |
1692 |
+- index = ncsi_find_filter(nc, table, data); |
1693 |
+- if (index >= 0) |
1694 |
+- return index; |
1695 |
+- |
1696 |
+- ncf = nc->filters[table]; |
1697 |
+- if (!ncf) |
1698 |
+- return -ENODEV; |
1699 |
+- |
1700 |
+- spin_lock_irqsave(&nc->lock, flags); |
1701 |
+- bitmap = (void *)&ncf->bitmap; |
1702 |
+- do { |
1703 |
+- index = find_next_zero_bit(bitmap, ncf->total, 0); |
1704 |
+- if (index >= ncf->total) { |
1705 |
+- spin_unlock_irqrestore(&nc->lock, flags); |
1706 |
+- return -ENOSPC; |
1707 |
+- } |
1708 |
+- } while (test_and_set_bit(index, bitmap)); |
1709 |
+- |
1710 |
+- memcpy(ncf->data + size * index, data, size); |
1711 |
+- spin_unlock_irqrestore(&nc->lock, flags); |
1712 |
+- |
1713 |
+- return index; |
1714 |
+-} |
1715 |
+- |
1716 |
+-int ncsi_remove_filter(struct ncsi_channel *nc, int table, int index) |
1717 |
+-{ |
1718 |
+- struct ncsi_channel_filter *ncf; |
1719 |
+- int size; |
1720 |
+- void *bitmap; |
1721 |
+- unsigned long flags; |
1722 |
+- |
1723 |
+- size = ncsi_filter_size(table); |
1724 |
+- if (size < 0) |
1725 |
+- return size; |
1726 |
+- |
1727 |
+- ncf = nc->filters[table]; |
1728 |
+- if (!ncf || index >= ncf->total) |
1729 |
+- return -ENODEV; |
1730 |
+- |
1731 |
+- spin_lock_irqsave(&nc->lock, flags); |
1732 |
+- bitmap = (void *)&ncf->bitmap; |
1733 |
+- if (test_and_clear_bit(index, bitmap)) |
1734 |
+- memset(ncf->data + size * index, 0, size); |
1735 |
+- spin_unlock_irqrestore(&nc->lock, flags); |
1736 |
+- |
1737 |
+- return 0; |
1738 |
+-} |
1739 |
+- |
1740 |
+ static void ncsi_report_link(struct ncsi_dev_priv *ndp, bool force_down) |
1741 |
+ { |
1742 |
+ struct ncsi_dev *nd = &ndp->ndev; |
1743 |
+@@ -203,13 +84,20 @@ static void ncsi_channel_monitor(unsigned long data) |
1744 |
+ monitor_state = nc->monitor.state; |
1745 |
+ spin_unlock_irqrestore(&nc->lock, flags); |
1746 |
+ |
1747 |
+- if (!enabled || chained) { |
1748 |
+- ncsi_stop_channel_monitor(nc); |
1749 |
+- return; |
1750 |
+- } |
1751 |
++ if (!enabled) |
1752 |
++ return; /* expected race disabling timer */ |
1753 |
++ if (WARN_ON_ONCE(chained)) |
1754 |
++ goto bad_state; |
1755 |
++ |
1756 |
+ if (state != NCSI_CHANNEL_INACTIVE && |
1757 |
+ state != NCSI_CHANNEL_ACTIVE) { |
1758 |
+- ncsi_stop_channel_monitor(nc); |
1759 |
++bad_state: |
1760 |
++ netdev_warn(ndp->ndev.dev, |
1761 |
++ "Bad NCSI monitor state channel %d 0x%x %s queue\n", |
1762 |
++ nc->id, state, chained ? "on" : "off"); |
1763 |
++ spin_lock_irqsave(&nc->lock, flags); |
1764 |
++ nc->monitor.enabled = false; |
1765 |
++ spin_unlock_irqrestore(&nc->lock, flags); |
1766 |
+ return; |
1767 |
+ } |
1768 |
+ |
1769 |
+@@ -229,15 +117,16 @@ static void ncsi_channel_monitor(unsigned long data) |
1770 |
+ case NCSI_CHANNEL_MONITOR_WAIT ... NCSI_CHANNEL_MONITOR_WAIT_MAX: |
1771 |
+ break; |
1772 |
+ default: |
1773 |
++ netdev_err(ndp->ndev.dev, "NCSI Channel %d timed out!\n", |
1774 |
++ nc->id); |
1775 |
+ if (!(ndp->flags & NCSI_DEV_HWA)) { |
1776 |
+ ncsi_report_link(ndp, true); |
1777 |
+ ndp->flags |= NCSI_DEV_RESHUFFLE; |
1778 |
+ } |
1779 |
+ |
1780 |
+- ncsi_stop_channel_monitor(nc); |
1781 |
+- |
1782 |
+ ncm = &nc->modes[NCSI_MODE_LINK]; |
1783 |
+ spin_lock_irqsave(&nc->lock, flags); |
1784 |
++ nc->monitor.enabled = false; |
1785 |
+ nc->state = NCSI_CHANNEL_INVISIBLE; |
1786 |
+ ncm->data[2] &= ~0x1; |
1787 |
+ spin_unlock_irqrestore(&nc->lock, flags); |
1788 |
+@@ -338,20 +227,13 @@ struct ncsi_channel *ncsi_add_channel(struct ncsi_package *np, unsigned char id) |
1789 |
+ static void ncsi_remove_channel(struct ncsi_channel *nc) |
1790 |
+ { |
1791 |
+ struct ncsi_package *np = nc->package; |
1792 |
+- struct ncsi_channel_filter *ncf; |
1793 |
+ unsigned long flags; |
1794 |
+- int i; |
1795 |
+ |
1796 |
+- /* Release filters */ |
1797 |
+ spin_lock_irqsave(&nc->lock, flags); |
1798 |
+- for (i = 0; i < NCSI_FILTER_MAX; i++) { |
1799 |
+- ncf = nc->filters[i]; |
1800 |
+- if (!ncf) |
1801 |
+- continue; |
1802 |
+ |
1803 |
+- nc->filters[i] = NULL; |
1804 |
+- kfree(ncf); |
1805 |
+- } |
1806 |
++ /* Release filters */ |
1807 |
++ kfree(nc->mac_filter.addrs); |
1808 |
++ kfree(nc->vlan_filter.vids); |
1809 |
+ |
1810 |
+ nc->state = NCSI_CHANNEL_INACTIVE; |
1811 |
+ spin_unlock_irqrestore(&nc->lock, flags); |
1812 |
+@@ -669,32 +551,26 @@ error: |
1813 |
+ static int clear_one_vid(struct ncsi_dev_priv *ndp, struct ncsi_channel *nc, |
1814 |
+ struct ncsi_cmd_arg *nca) |
1815 |
+ { |
1816 |
++ struct ncsi_channel_vlan_filter *ncf; |
1817 |
++ unsigned long flags; |
1818 |
++ void *bitmap; |
1819 |
+ int index; |
1820 |
+- u32 *data; |
1821 |
+ u16 vid; |
1822 |
+ |
1823 |
+- index = ncsi_find_filter(nc, NCSI_FILTER_VLAN, NULL); |
1824 |
+- if (index < 0) { |
1825 |
+- /* Filter table empty */ |
1826 |
+- return -1; |
1827 |
+- } |
1828 |
++ ncf = &nc->vlan_filter; |
1829 |
++ bitmap = &ncf->bitmap; |
1830 |
+ |
1831 |
+- data = ncsi_get_filter(nc, NCSI_FILTER_VLAN, index); |
1832 |
+- if (!data) { |
1833 |
+- netdev_err(ndp->ndev.dev, |
1834 |
+- "ncsi: failed to retrieve filter %d\n", index); |
1835 |
+- /* Set the VLAN id to 0 - this will still disable the entry in |
1836 |
+- * the filter table, but we won't know what it was. |
1837 |
+- */ |
1838 |
+- vid = 0; |
1839 |
+- } else { |
1840 |
+- vid = *(u16 *)data; |
1841 |
++ spin_lock_irqsave(&nc->lock, flags); |
1842 |
++ index = find_next_bit(bitmap, ncf->n_vids, 0); |
1843 |
++ if (index >= ncf->n_vids) { |
1844 |
++ spin_unlock_irqrestore(&nc->lock, flags); |
1845 |
++ return -1; |
1846 |
+ } |
1847 |
++ vid = ncf->vids[index]; |
1848 |
+ |
1849 |
+- netdev_printk(KERN_DEBUG, ndp->ndev.dev, |
1850 |
+- "ncsi: removed vlan tag %u at index %d\n", |
1851 |
+- vid, index + 1); |
1852 |
+- ncsi_remove_filter(nc, NCSI_FILTER_VLAN, index); |
1853 |
++ clear_bit(index, bitmap); |
1854 |
++ ncf->vids[index] = 0; |
1855 |
++ spin_unlock_irqrestore(&nc->lock, flags); |
1856 |
+ |
1857 |
+ nca->type = NCSI_PKT_CMD_SVF; |
1858 |
+ nca->words[1] = vid; |
1859 |
+@@ -710,45 +586,55 @@ static int clear_one_vid(struct ncsi_dev_priv *ndp, struct ncsi_channel *nc, |
1860 |
+ static int set_one_vid(struct ncsi_dev_priv *ndp, struct ncsi_channel *nc, |
1861 |
+ struct ncsi_cmd_arg *nca) |
1862 |
+ { |
1863 |
++ struct ncsi_channel_vlan_filter *ncf; |
1864 |
+ struct vlan_vid *vlan = NULL; |
1865 |
+- int index = 0; |
1866 |
++ unsigned long flags; |
1867 |
++ int i, index; |
1868 |
++ void *bitmap; |
1869 |
++ u16 vid; |
1870 |
++ |
1871 |
++ if (list_empty(&ndp->vlan_vids)) |
1872 |
++ return -1; |
1873 |
++ |
1874 |
++ ncf = &nc->vlan_filter; |
1875 |
++ bitmap = &ncf->bitmap; |
1876 |
+ |
1877 |
++ spin_lock_irqsave(&nc->lock, flags); |
1878 |
++ |
1879 |
++ rcu_read_lock(); |
1880 |
+ list_for_each_entry_rcu(vlan, &ndp->vlan_vids, list) { |
1881 |
+- index = ncsi_find_filter(nc, NCSI_FILTER_VLAN, &vlan->vid); |
1882 |
+- if (index < 0) { |
1883 |
+- /* New tag to add */ |
1884 |
+- netdev_printk(KERN_DEBUG, ndp->ndev.dev, |
1885 |
+- "ncsi: new vlan id to set: %u\n", |
1886 |
+- vlan->vid); |
1887 |
++ vid = vlan->vid; |
1888 |
++ for (i = 0; i < ncf->n_vids; i++) |
1889 |
++ if (ncf->vids[i] == vid) { |
1890 |
++ vid = 0; |
1891 |
++ break; |
1892 |
++ } |
1893 |
++ if (vid) |
1894 |
+ break; |
1895 |
+- } |
1896 |
+- netdev_printk(KERN_DEBUG, ndp->ndev.dev, |
1897 |
+- "vid %u already at filter pos %d\n", |
1898 |
+- vlan->vid, index); |
1899 |
+ } |
1900 |
++ rcu_read_unlock(); |
1901 |
+ |
1902 |
+- if (!vlan || index >= 0) { |
1903 |
+- netdev_printk(KERN_DEBUG, ndp->ndev.dev, |
1904 |
+- "no vlan ids left to set\n"); |
1905 |
++ if (!vid) { |
1906 |
++ /* No VLAN ID is not set */ |
1907 |
++ spin_unlock_irqrestore(&nc->lock, flags); |
1908 |
+ return -1; |
1909 |
+ } |
1910 |
+ |
1911 |
+- index = ncsi_add_filter(nc, NCSI_FILTER_VLAN, &vlan->vid); |
1912 |
+- if (index < 0) { |
1913 |
++ index = find_next_zero_bit(bitmap, ncf->n_vids, 0); |
1914 |
++ if (index < 0 || index >= ncf->n_vids) { |
1915 |
+ netdev_err(ndp->ndev.dev, |
1916 |
+- "Failed to add new VLAN tag, error %d\n", index); |
1917 |
+- if (index == -ENOSPC) |
1918 |
+- netdev_err(ndp->ndev.dev, |
1919 |
+- "Channel %u already has all VLAN filters set\n", |
1920 |
+- nc->id); |
1921 |
++ "Channel %u already has all VLAN filters set\n", |
1922 |
++ nc->id); |
1923 |
++ spin_unlock_irqrestore(&nc->lock, flags); |
1924 |
+ return -1; |
1925 |
+ } |
1926 |
+ |
1927 |
+- netdev_printk(KERN_DEBUG, ndp->ndev.dev, |
1928 |
+- "ncsi: set vid %u in packet, index %u\n", |
1929 |
+- vlan->vid, index + 1); |
1930 |
++ ncf->vids[index] = vid; |
1931 |
++ set_bit(index, bitmap); |
1932 |
++ spin_unlock_irqrestore(&nc->lock, flags); |
1933 |
++ |
1934 |
+ nca->type = NCSI_PKT_CMD_SVF; |
1935 |
+- nca->words[1] = vlan->vid; |
1936 |
++ nca->words[1] = vid; |
1937 |
+ /* HW filter index starts at 1 */ |
1938 |
+ nca->bytes[6] = index + 1; |
1939 |
+ nca->bytes[7] = 0x01; |
1940 |
+@@ -784,8 +670,11 @@ static void ncsi_configure_channel(struct ncsi_dev_priv *ndp) |
1941 |
+ nca.package = np->id; |
1942 |
+ nca.channel = NCSI_RESERVED_CHANNEL; |
1943 |
+ ret = ncsi_xmit_cmd(&nca); |
1944 |
+- if (ret) |
1945 |
++ if (ret) { |
1946 |
++ netdev_err(ndp->ndev.dev, |
1947 |
++ "NCSI: Failed to transmit CMD_SP\n"); |
1948 |
+ goto error; |
1949 |
++ } |
1950 |
+ |
1951 |
+ nd->state = ncsi_dev_state_config_cis; |
1952 |
+ break; |
1953 |
+@@ -797,8 +686,11 @@ static void ncsi_configure_channel(struct ncsi_dev_priv *ndp) |
1954 |
+ nca.package = np->id; |
1955 |
+ nca.channel = nc->id; |
1956 |
+ ret = ncsi_xmit_cmd(&nca); |
1957 |
+- if (ret) |
1958 |
++ if (ret) { |
1959 |
++ netdev_err(ndp->ndev.dev, |
1960 |
++ "NCSI: Failed to transmit CMD_CIS\n"); |
1961 |
+ goto error; |
1962 |
++ } |
1963 |
+ |
1964 |
+ nd->state = ncsi_dev_state_config_clear_vids; |
1965 |
+ break; |
1966 |
+@@ -895,10 +787,16 @@ static void ncsi_configure_channel(struct ncsi_dev_priv *ndp) |
1967 |
+ } |
1968 |
+ |
1969 |
+ ret = ncsi_xmit_cmd(&nca); |
1970 |
+- if (ret) |
1971 |
++ if (ret) { |
1972 |
++ netdev_err(ndp->ndev.dev, |
1973 |
++ "NCSI: Failed to transmit CMD %x\n", |
1974 |
++ nca.type); |
1975 |
+ goto error; |
1976 |
++ } |
1977 |
+ break; |
1978 |
+ case ncsi_dev_state_config_done: |
1979 |
++ netdev_printk(KERN_DEBUG, ndp->ndev.dev, |
1980 |
++ "NCSI: channel %u config done\n", nc->id); |
1981 |
+ spin_lock_irqsave(&nc->lock, flags); |
1982 |
+ if (nc->reconfigure_needed) { |
1983 |
+ /* This channel's configuration has been updated |
1984 |
+@@ -925,6 +823,9 @@ static void ncsi_configure_channel(struct ncsi_dev_priv *ndp) |
1985 |
+ } else { |
1986 |
+ hot_nc = NULL; |
1987 |
+ nc->state = NCSI_CHANNEL_INACTIVE; |
1988 |
++ netdev_warn(ndp->ndev.dev, |
1989 |
++ "NCSI: channel %u link down after config\n", |
1990 |
++ nc->id); |
1991 |
+ } |
1992 |
+ spin_unlock_irqrestore(&nc->lock, flags); |
1993 |
+ |
1994 |
+@@ -937,8 +838,8 @@ static void ncsi_configure_channel(struct ncsi_dev_priv *ndp) |
1995 |
+ ncsi_process_next_channel(ndp); |
1996 |
+ break; |
1997 |
+ default: |
1998 |
+- netdev_warn(dev, "Wrong NCSI state 0x%x in config\n", |
1999 |
+- nd->state); |
2000 |
++ netdev_alert(dev, "Wrong NCSI state 0x%x in config\n", |
2001 |
++ nd->state); |
2002 |
+ } |
2003 |
+ |
2004 |
+ return; |
2005 |
+@@ -949,20 +850,37 @@ error: |
2006 |
+ |
2007 |
+ static int ncsi_choose_active_channel(struct ncsi_dev_priv *ndp) |
2008 |
+ { |
2009 |
+- struct ncsi_package *np; |
2010 |
+- struct ncsi_channel *nc, *found, *hot_nc; |
2011 |
++ struct ncsi_package *np, *force_package; |
2012 |
++ struct ncsi_channel *nc, *found, *hot_nc, *force_channel; |
2013 |
+ struct ncsi_channel_mode *ncm; |
2014 |
+ unsigned long flags; |
2015 |
+ |
2016 |
+ spin_lock_irqsave(&ndp->lock, flags); |
2017 |
+ hot_nc = ndp->hot_channel; |
2018 |
++ force_channel = ndp->force_channel; |
2019 |
++ force_package = ndp->force_package; |
2020 |
+ spin_unlock_irqrestore(&ndp->lock, flags); |
2021 |
+ |
2022 |
++ /* Force a specific channel whether or not it has link if we have been |
2023 |
++ * configured to do so |
2024 |
++ */ |
2025 |
++ if (force_package && force_channel) { |
2026 |
++ found = force_channel; |
2027 |
++ ncm = &found->modes[NCSI_MODE_LINK]; |
2028 |
++ if (!(ncm->data[2] & 0x1)) |
2029 |
++ netdev_info(ndp->ndev.dev, |
2030 |
++ "NCSI: Channel %u forced, but it is link down\n", |
2031 |
++ found->id); |
2032 |
++ goto out; |
2033 |
++ } |
2034 |
++ |
2035 |
+ /* The search is done once an inactive channel with up |
2036 |
+ * link is found. |
2037 |
+ */ |
2038 |
+ found = NULL; |
2039 |
+ NCSI_FOR_EACH_PACKAGE(ndp, np) { |
2040 |
++ if (ndp->force_package && np != ndp->force_package) |
2041 |
++ continue; |
2042 |
+ NCSI_FOR_EACH_CHANNEL(np, nc) { |
2043 |
+ spin_lock_irqsave(&nc->lock, flags); |
2044 |
+ |
2045 |
+@@ -990,10 +908,17 @@ static int ncsi_choose_active_channel(struct ncsi_dev_priv *ndp) |
2046 |
+ } |
2047 |
+ |
2048 |
+ if (!found) { |
2049 |
++ netdev_warn(ndp->ndev.dev, |
2050 |
++ "NCSI: No channel found with link\n"); |
2051 |
+ ncsi_report_link(ndp, true); |
2052 |
+ return -ENODEV; |
2053 |
+ } |
2054 |
+ |
2055 |
++ ncm = &found->modes[NCSI_MODE_LINK]; |
2056 |
++ netdev_printk(KERN_DEBUG, ndp->ndev.dev, |
2057 |
++ "NCSI: Channel %u added to queue (link %s)\n", |
2058 |
++ found->id, ncm->data[2] & 0x1 ? "up" : "down"); |
2059 |
++ |
2060 |
+ out: |
2061 |
+ spin_lock_irqsave(&ndp->lock, flags); |
2062 |
+ list_add_tail_rcu(&found->link, &ndp->channel_queue); |
2063 |
+@@ -1055,6 +980,8 @@ static int ncsi_enable_hwa(struct ncsi_dev_priv *ndp) |
2064 |
+ |
2065 |
+ /* We can have no channels in extremely case */ |
2066 |
+ if (list_empty(&ndp->channel_queue)) { |
2067 |
++ netdev_err(ndp->ndev.dev, |
2068 |
++ "NCSI: No available channels for HWA\n"); |
2069 |
+ ncsi_report_link(ndp, false); |
2070 |
+ return -ENOENT; |
2071 |
+ } |
2072 |
+@@ -1223,6 +1150,9 @@ static void ncsi_probe_channel(struct ncsi_dev_priv *ndp) |
2073 |
+ |
2074 |
+ return; |
2075 |
+ error: |
2076 |
++ netdev_err(ndp->ndev.dev, |
2077 |
++ "NCSI: Failed to transmit cmd 0x%x during probe\n", |
2078 |
++ nca.type); |
2079 |
+ ncsi_report_link(ndp, true); |
2080 |
+ } |
2081 |
+ |
2082 |
+@@ -1276,10 +1206,14 @@ int ncsi_process_next_channel(struct ncsi_dev_priv *ndp) |
2083 |
+ switch (old_state) { |
2084 |
+ case NCSI_CHANNEL_INACTIVE: |
2085 |
+ ndp->ndev.state = ncsi_dev_state_config; |
2086 |
++ netdev_info(ndp->ndev.dev, "NCSI: configuring channel %u\n", |
2087 |
++ nc->id); |
2088 |
+ ncsi_configure_channel(ndp); |
2089 |
+ break; |
2090 |
+ case NCSI_CHANNEL_ACTIVE: |
2091 |
+ ndp->ndev.state = ncsi_dev_state_suspend; |
2092 |
++ netdev_info(ndp->ndev.dev, "NCSI: suspending channel %u\n", |
2093 |
++ nc->id); |
2094 |
+ ncsi_suspend_channel(ndp); |
2095 |
+ break; |
2096 |
+ default: |
2097 |
+@@ -1299,6 +1233,8 @@ out: |
2098 |
+ return ncsi_choose_active_channel(ndp); |
2099 |
+ } |
2100 |
+ |
2101 |
++ netdev_printk(KERN_DEBUG, ndp->ndev.dev, |
2102 |
++ "NCSI: No more channels to process\n"); |
2103 |
+ ncsi_report_link(ndp, false); |
2104 |
+ return -ENODEV; |
2105 |
+ } |
2106 |
+@@ -1390,7 +1326,7 @@ static int ncsi_kick_channels(struct ncsi_dev_priv *ndp) |
2107 |
+ ncsi_dev_state_config || |
2108 |
+ !list_empty(&nc->link)) { |
2109 |
+ netdev_printk(KERN_DEBUG, nd->dev, |
2110 |
+- "ncsi: channel %p marked dirty\n", |
2111 |
++ "NCSI: channel %p marked dirty\n", |
2112 |
+ nc); |
2113 |
+ nc->reconfigure_needed = true; |
2114 |
+ } |
2115 |
+@@ -1410,7 +1346,7 @@ static int ncsi_kick_channels(struct ncsi_dev_priv *ndp) |
2116 |
+ spin_unlock_irqrestore(&ndp->lock, flags); |
2117 |
+ |
2118 |
+ netdev_printk(KERN_DEBUG, nd->dev, |
2119 |
+- "ncsi: kicked channel %p\n", nc); |
2120 |
++ "NCSI: kicked channel %p\n", nc); |
2121 |
+ n++; |
2122 |
+ } |
2123 |
+ } |
2124 |
+@@ -1431,7 +1367,7 @@ int ncsi_vlan_rx_add_vid(struct net_device *dev, __be16 proto, u16 vid) |
2125 |
+ |
2126 |
+ nd = ncsi_find_dev(dev); |
2127 |
+ if (!nd) { |
2128 |
+- netdev_warn(dev, "ncsi: No net_device?\n"); |
2129 |
++ netdev_warn(dev, "NCSI: No net_device?\n"); |
2130 |
+ return 0; |
2131 |
+ } |
2132 |
+ |
2133 |
+@@ -1442,7 +1378,7 @@ int ncsi_vlan_rx_add_vid(struct net_device *dev, __be16 proto, u16 vid) |
2134 |
+ n_vids++; |
2135 |
+ if (vlan->vid == vid) { |
2136 |
+ netdev_printk(KERN_DEBUG, dev, |
2137 |
+- "vid %u already registered\n", vid); |
2138 |
++ "NCSI: vid %u already registered\n", vid); |
2139 |
+ return 0; |
2140 |
+ } |
2141 |
+ } |
2142 |
+@@ -1461,7 +1397,7 @@ int ncsi_vlan_rx_add_vid(struct net_device *dev, __be16 proto, u16 vid) |
2143 |
+ vlan->vid = vid; |
2144 |
+ list_add_rcu(&vlan->list, &ndp->vlan_vids); |
2145 |
+ |
2146 |
+- netdev_printk(KERN_DEBUG, dev, "Added new vid %u\n", vid); |
2147 |
++ netdev_printk(KERN_DEBUG, dev, "NCSI: Added new vid %u\n", vid); |
2148 |
+ |
2149 |
+ found = ncsi_kick_channels(ndp) != 0; |
2150 |
+ |
2151 |
+@@ -1481,7 +1417,7 @@ int ncsi_vlan_rx_kill_vid(struct net_device *dev, __be16 proto, u16 vid) |
2152 |
+ |
2153 |
+ nd = ncsi_find_dev(dev); |
2154 |
+ if (!nd) { |
2155 |
+- netdev_warn(dev, "ncsi: no net_device?\n"); |
2156 |
++ netdev_warn(dev, "NCSI: no net_device?\n"); |
2157 |
+ return 0; |
2158 |
+ } |
2159 |
+ |
2160 |
+@@ -1491,14 +1427,14 @@ int ncsi_vlan_rx_kill_vid(struct net_device *dev, __be16 proto, u16 vid) |
2161 |
+ list_for_each_entry_safe(vlan, tmp, &ndp->vlan_vids, list) |
2162 |
+ if (vlan->vid == vid) { |
2163 |
+ netdev_printk(KERN_DEBUG, dev, |
2164 |
+- "vid %u found, removing\n", vid); |
2165 |
++ "NCSI: vid %u found, removing\n", vid); |
2166 |
+ list_del_rcu(&vlan->list); |
2167 |
+ found = true; |
2168 |
+ kfree(vlan); |
2169 |
+ } |
2170 |
+ |
2171 |
+ if (!found) { |
2172 |
+- netdev_err(dev, "ncsi: vid %u wasn't registered!\n", vid); |
2173 |
++ netdev_err(dev, "NCSI: vid %u wasn't registered!\n", vid); |
2174 |
+ return -EINVAL; |
2175 |
+ } |
2176 |
+ |
2177 |
+@@ -1562,6 +1498,9 @@ struct ncsi_dev *ncsi_register_dev(struct net_device *dev, |
2178 |
+ ndp->ptype.dev = dev; |
2179 |
+ dev_add_pack(&ndp->ptype); |
2180 |
+ |
2181 |
++ /* Set up generic netlink interface */ |
2182 |
++ ncsi_init_netlink(dev); |
2183 |
++ |
2184 |
+ return nd; |
2185 |
+ } |
2186 |
+ EXPORT_SYMBOL_GPL(ncsi_register_dev); |
2187 |
+@@ -1581,10 +1520,12 @@ int ncsi_start_dev(struct ncsi_dev *nd) |
2188 |
+ return 0; |
2189 |
+ } |
2190 |
+ |
2191 |
+- if (ndp->flags & NCSI_DEV_HWA) |
2192 |
++ if (ndp->flags & NCSI_DEV_HWA) { |
2193 |
++ netdev_info(ndp->ndev.dev, "NCSI: Enabling HWA mode\n"); |
2194 |
+ ret = ncsi_enable_hwa(ndp); |
2195 |
+- else |
2196 |
++ } else { |
2197 |
+ ret = ncsi_choose_active_channel(ndp); |
2198 |
++ } |
2199 |
+ |
2200 |
+ return ret; |
2201 |
+ } |
2202 |
+@@ -1615,6 +1556,7 @@ void ncsi_stop_dev(struct ncsi_dev *nd) |
2203 |
+ } |
2204 |
+ } |
2205 |
+ |
2206 |
++ netdev_printk(KERN_DEBUG, ndp->ndev.dev, "NCSI: Stopping device\n"); |
2207 |
+ ncsi_report_link(ndp, true); |
2208 |
+ } |
2209 |
+ EXPORT_SYMBOL_GPL(ncsi_stop_dev); |
2210 |
+@@ -1638,6 +1580,8 @@ void ncsi_unregister_dev(struct ncsi_dev *nd) |
2211 |
+ #endif |
2212 |
+ spin_unlock_irqrestore(&ncsi_dev_lock, flags); |
2213 |
+ |
2214 |
++ ncsi_unregister_netlink(nd->dev); |
2215 |
++ |
2216 |
+ kfree(ndp); |
2217 |
+ } |
2218 |
+ EXPORT_SYMBOL_GPL(ncsi_unregister_dev); |
2219 |
+diff --git a/net/ncsi/ncsi-netlink.c b/net/ncsi/ncsi-netlink.c |
2220 |
+new file mode 100644 |
2221 |
+index 0000000000000..9073911ac97b3 |
2222 |
+--- /dev/null |
2223 |
++++ b/net/ncsi/ncsi-netlink.c |
2224 |
+@@ -0,0 +1,415 @@ |
2225 |
++/* |
2226 |
++ * Copyright Samuel Mendoza-Jonas, IBM Corporation 2018. |
2227 |
++ * |
2228 |
++ * This program is free software; you can redistribute it and/or modify |
2229 |
++ * it under the terms of the GNU General Public License as published by |
2230 |
++ * the Free Software Foundation; either version 2 of the License, or |
2231 |
++ * (at your option) any later version. |
2232 |
++ */ |
2233 |
++ |
2234 |
++#include <linux/module.h> |
2235 |
++#include <linux/kernel.h> |
2236 |
++#include <linux/if_arp.h> |
2237 |
++#include <linux/rtnetlink.h> |
2238 |
++#include <linux/etherdevice.h> |
2239 |
++#include <linux/module.h> |
2240 |
++#include <net/genetlink.h> |
2241 |
++#include <net/ncsi.h> |
2242 |
++#include <linux/skbuff.h> |
2243 |
++#include <net/sock.h> |
2244 |
++#include <uapi/linux/ncsi.h> |
2245 |
++ |
2246 |
++#include "internal.h" |
2247 |
++#include "ncsi-netlink.h" |
2248 |
++ |
2249 |
++static struct genl_family ncsi_genl_family; |
2250 |
++ |
2251 |
++static const struct nla_policy ncsi_genl_policy[NCSI_ATTR_MAX + 1] = { |
2252 |
++ [NCSI_ATTR_IFINDEX] = { .type = NLA_U32 }, |
2253 |
++ [NCSI_ATTR_PACKAGE_LIST] = { .type = NLA_NESTED }, |
2254 |
++ [NCSI_ATTR_PACKAGE_ID] = { .type = NLA_U32 }, |
2255 |
++ [NCSI_ATTR_CHANNEL_ID] = { .type = NLA_U32 }, |
2256 |
++}; |
2257 |
++ |
2258 |
++static struct ncsi_dev_priv *ndp_from_ifindex(struct net *net, u32 ifindex) |
2259 |
++{ |
2260 |
++ struct ncsi_dev_priv *ndp; |
2261 |
++ struct net_device *dev; |
2262 |
++ struct ncsi_dev *nd; |
2263 |
++ struct ncsi_dev; |
2264 |
++ |
2265 |
++ if (!net) |
2266 |
++ return NULL; |
2267 |
++ |
2268 |
++ dev = dev_get_by_index(net, ifindex); |
2269 |
++ if (!dev) { |
2270 |
++ pr_err("NCSI netlink: No device for ifindex %u\n", ifindex); |
2271 |
++ return NULL; |
2272 |
++ } |
2273 |
++ |
2274 |
++ nd = ncsi_find_dev(dev); |
2275 |
++ ndp = nd ? TO_NCSI_DEV_PRIV(nd) : NULL; |
2276 |
++ |
2277 |
++ dev_put(dev); |
2278 |
++ return ndp; |
2279 |
++} |
2280 |
++ |
2281 |
++static int ncsi_write_channel_info(struct sk_buff *skb, |
2282 |
++ struct ncsi_dev_priv *ndp, |
2283 |
++ struct ncsi_channel *nc) |
2284 |
++{ |
2285 |
++ struct ncsi_channel_vlan_filter *ncf; |
2286 |
++ struct ncsi_channel_mode *m; |
2287 |
++ struct nlattr *vid_nest; |
2288 |
++ int i; |
2289 |
++ |
2290 |
++ nla_put_u32(skb, NCSI_CHANNEL_ATTR_ID, nc->id); |
2291 |
++ m = &nc->modes[NCSI_MODE_LINK]; |
2292 |
++ nla_put_u32(skb, NCSI_CHANNEL_ATTR_LINK_STATE, m->data[2]); |
2293 |
++ if (nc->state == NCSI_CHANNEL_ACTIVE) |
2294 |
++ nla_put_flag(skb, NCSI_CHANNEL_ATTR_ACTIVE); |
2295 |
++ if (ndp->force_channel == nc) |
2296 |
++ nla_put_flag(skb, NCSI_CHANNEL_ATTR_FORCED); |
2297 |
++ |
2298 |
++ nla_put_u32(skb, NCSI_CHANNEL_ATTR_VERSION_MAJOR, nc->version.version); |
2299 |
++ nla_put_u32(skb, NCSI_CHANNEL_ATTR_VERSION_MINOR, nc->version.alpha2); |
2300 |
++ nla_put_string(skb, NCSI_CHANNEL_ATTR_VERSION_STR, nc->version.fw_name); |
2301 |
++ |
2302 |
++ vid_nest = nla_nest_start(skb, NCSI_CHANNEL_ATTR_VLAN_LIST); |
2303 |
++ if (!vid_nest) |
2304 |
++ return -ENOMEM; |
2305 |
++ ncf = &nc->vlan_filter; |
2306 |
++ i = -1; |
2307 |
++ while ((i = find_next_bit((void *)&ncf->bitmap, ncf->n_vids, |
2308 |
++ i + 1)) < ncf->n_vids) { |
2309 |
++ if (ncf->vids[i]) |
2310 |
++ nla_put_u16(skb, NCSI_CHANNEL_ATTR_VLAN_ID, |
2311 |
++ ncf->vids[i]); |
2312 |
++ } |
2313 |
++ nla_nest_end(skb, vid_nest); |
2314 |
++ |
2315 |
++ return 0; |
2316 |
++} |
2317 |
++ |
2318 |
++static int ncsi_write_package_info(struct sk_buff *skb, |
2319 |
++ struct ncsi_dev_priv *ndp, unsigned int id) |
2320 |
++{ |
2321 |
++ struct nlattr *pnest, *cnest, *nest; |
2322 |
++ struct ncsi_package *np; |
2323 |
++ struct ncsi_channel *nc; |
2324 |
++ bool found; |
2325 |
++ int rc; |
2326 |
++ |
2327 |
++ if (id > ndp->package_num) { |
2328 |
++ netdev_info(ndp->ndev.dev, "NCSI: No package with id %u\n", id); |
2329 |
++ return -ENODEV; |
2330 |
++ } |
2331 |
++ |
2332 |
++ found = false; |
2333 |
++ NCSI_FOR_EACH_PACKAGE(ndp, np) { |
2334 |
++ if (np->id != id) |
2335 |
++ continue; |
2336 |
++ pnest = nla_nest_start(skb, NCSI_PKG_ATTR); |
2337 |
++ if (!pnest) |
2338 |
++ return -ENOMEM; |
2339 |
++ nla_put_u32(skb, NCSI_PKG_ATTR_ID, np->id); |
2340 |
++ if (ndp->force_package == np) |
2341 |
++ nla_put_flag(skb, NCSI_PKG_ATTR_FORCED); |
2342 |
++ cnest = nla_nest_start(skb, NCSI_PKG_ATTR_CHANNEL_LIST); |
2343 |
++ if (!cnest) { |
2344 |
++ nla_nest_cancel(skb, pnest); |
2345 |
++ return -ENOMEM; |
2346 |
++ } |
2347 |
++ NCSI_FOR_EACH_CHANNEL(np, nc) { |
2348 |
++ nest = nla_nest_start(skb, NCSI_CHANNEL_ATTR); |
2349 |
++ if (!nest) { |
2350 |
++ nla_nest_cancel(skb, cnest); |
2351 |
++ nla_nest_cancel(skb, pnest); |
2352 |
++ return -ENOMEM; |
2353 |
++ } |
2354 |
++ rc = ncsi_write_channel_info(skb, ndp, nc); |
2355 |
++ if (rc) { |
2356 |
++ nla_nest_cancel(skb, nest); |
2357 |
++ nla_nest_cancel(skb, cnest); |
2358 |
++ nla_nest_cancel(skb, pnest); |
2359 |
++ return rc; |
2360 |
++ } |
2361 |
++ nla_nest_end(skb, nest); |
2362 |
++ } |
2363 |
++ nla_nest_end(skb, cnest); |
2364 |
++ nla_nest_end(skb, pnest); |
2365 |
++ found = true; |
2366 |
++ } |
2367 |
++ |
2368 |
++ if (!found) |
2369 |
++ return -ENODEV; |
2370 |
++ |
2371 |
++ return 0; |
2372 |
++} |
2373 |
++ |
2374 |
++static int ncsi_pkg_info_nl(struct sk_buff *msg, struct genl_info *info) |
2375 |
++{ |
2376 |
++ struct ncsi_dev_priv *ndp; |
2377 |
++ unsigned int package_id; |
2378 |
++ struct sk_buff *skb; |
2379 |
++ struct nlattr *attr; |
2380 |
++ void *hdr; |
2381 |
++ int rc; |
2382 |
++ |
2383 |
++ if (!info || !info->attrs) |
2384 |
++ return -EINVAL; |
2385 |
++ |
2386 |
++ if (!info->attrs[NCSI_ATTR_IFINDEX]) |
2387 |
++ return -EINVAL; |
2388 |
++ |
2389 |
++ if (!info->attrs[NCSI_ATTR_PACKAGE_ID]) |
2390 |
++ return -EINVAL; |
2391 |
++ |
2392 |
++ ndp = ndp_from_ifindex(genl_info_net(info), |
2393 |
++ nla_get_u32(info->attrs[NCSI_ATTR_IFINDEX])); |
2394 |
++ if (!ndp) |
2395 |
++ return -ENODEV; |
2396 |
++ |
2397 |
++ skb = genlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL); |
2398 |
++ if (!skb) |
2399 |
++ return -ENOMEM; |
2400 |
++ |
2401 |
++ hdr = genlmsg_put(skb, info->snd_portid, info->snd_seq, |
2402 |
++ &ncsi_genl_family, 0, NCSI_CMD_PKG_INFO); |
2403 |
++ if (!hdr) { |
2404 |
++ kfree(skb); |
2405 |
++ return -EMSGSIZE; |
2406 |
++ } |
2407 |
++ |
2408 |
++ package_id = nla_get_u32(info->attrs[NCSI_ATTR_PACKAGE_ID]); |
2409 |
++ |
2410 |
++ attr = nla_nest_start(skb, NCSI_ATTR_PACKAGE_LIST); |
2411 |
++ rc = ncsi_write_package_info(skb, ndp, package_id); |
2412 |
++ |
2413 |
++ if (rc) { |
2414 |
++ nla_nest_cancel(skb, attr); |
2415 |
++ goto err; |
2416 |
++ } |
2417 |
++ |
2418 |
++ nla_nest_end(skb, attr); |
2419 |
++ |
2420 |
++ genlmsg_end(skb, hdr); |
2421 |
++ return genlmsg_reply(skb, info); |
2422 |
++ |
2423 |
++err: |
2424 |
++ genlmsg_cancel(skb, hdr); |
2425 |
++ kfree(skb); |
2426 |
++ return rc; |
2427 |
++} |
2428 |
++ |
2429 |
++static int ncsi_pkg_info_all_nl(struct sk_buff *skb, |
2430 |
++ struct netlink_callback *cb) |
2431 |
++{ |
2432 |
++ struct nlattr *attrs[NCSI_ATTR_MAX]; |
2433 |
++ struct ncsi_package *np, *package; |
2434 |
++ struct ncsi_dev_priv *ndp; |
2435 |
++ unsigned int package_id; |
2436 |
++ struct nlattr *attr; |
2437 |
++ void *hdr; |
2438 |
++ int rc; |
2439 |
++ |
2440 |
++ rc = genlmsg_parse(cb->nlh, &ncsi_genl_family, attrs, NCSI_ATTR_MAX, |
2441 |
++ ncsi_genl_policy, NULL); |
2442 |
++ if (rc) |
2443 |
++ return rc; |
2444 |
++ |
2445 |
++ if (!attrs[NCSI_ATTR_IFINDEX]) |
2446 |
++ return -EINVAL; |
2447 |
++ |
2448 |
++ ndp = ndp_from_ifindex(get_net(sock_net(skb->sk)), |
2449 |
++ nla_get_u32(attrs[NCSI_ATTR_IFINDEX])); |
2450 |
++ |
2451 |
++ if (!ndp) |
2452 |
++ return -ENODEV; |
2453 |
++ |
2454 |
++ package_id = cb->args[0]; |
2455 |
++ package = NULL; |
2456 |
++ NCSI_FOR_EACH_PACKAGE(ndp, np) |
2457 |
++ if (np->id == package_id) |
2458 |
++ package = np; |
2459 |
++ |
2460 |
++ if (!package) |
2461 |
++ return 0; /* done */ |
2462 |
++ |
2463 |
++ hdr = genlmsg_put(skb, NETLINK_CB(cb->skb).portid, cb->nlh->nlmsg_seq, |
2464 |
++ &ncsi_genl_family, 0, NCSI_CMD_PKG_INFO); |
2465 |
++ if (!hdr) { |
2466 |
++ rc = -EMSGSIZE; |
2467 |
++ goto err; |
2468 |
++ } |
2469 |
++ |
2470 |
++ attr = nla_nest_start(skb, NCSI_ATTR_PACKAGE_LIST); |
2471 |
++ rc = ncsi_write_package_info(skb, ndp, package->id); |
2472 |
++ if (rc) { |
2473 |
++ nla_nest_cancel(skb, attr); |
2474 |
++ goto err; |
2475 |
++ } |
2476 |
++ |
2477 |
++ nla_nest_end(skb, attr); |
2478 |
++ genlmsg_end(skb, hdr); |
2479 |
++ |
2480 |
++ cb->args[0] = package_id + 1; |
2481 |
++ |
2482 |
++ return skb->len; |
2483 |
++err: |
2484 |
++ genlmsg_cancel(skb, hdr); |
2485 |
++ return rc; |
2486 |
++} |
2487 |
++ |
2488 |
++static int ncsi_set_interface_nl(struct sk_buff *msg, struct genl_info *info) |
2489 |
++{ |
2490 |
++ struct ncsi_package *np, *package; |
2491 |
++ struct ncsi_channel *nc, *channel; |
2492 |
++ u32 package_id, channel_id; |
2493 |
++ struct ncsi_dev_priv *ndp; |
2494 |
++ unsigned long flags; |
2495 |
++ |
2496 |
++ if (!info || !info->attrs) |
2497 |
++ return -EINVAL; |
2498 |
++ |
2499 |
++ if (!info->attrs[NCSI_ATTR_IFINDEX]) |
2500 |
++ return -EINVAL; |
2501 |
++ |
2502 |
++ if (!info->attrs[NCSI_ATTR_PACKAGE_ID]) |
2503 |
++ return -EINVAL; |
2504 |
++ |
2505 |
++ ndp = ndp_from_ifindex(get_net(sock_net(msg->sk)), |
2506 |
++ nla_get_u32(info->attrs[NCSI_ATTR_IFINDEX])); |
2507 |
++ if (!ndp) |
2508 |
++ return -ENODEV; |
2509 |
++ |
2510 |
++ package_id = nla_get_u32(info->attrs[NCSI_ATTR_PACKAGE_ID]); |
2511 |
++ package = NULL; |
2512 |
++ |
2513 |
++ spin_lock_irqsave(&ndp->lock, flags); |
2514 |
++ |
2515 |
++ NCSI_FOR_EACH_PACKAGE(ndp, np) |
2516 |
++ if (np->id == package_id) |
2517 |
++ package = np; |
2518 |
++ if (!package) { |
2519 |
++ /* The user has set a package that does not exist */ |
2520 |
++ return -ERANGE; |
2521 |
++ } |
2522 |
++ |
2523 |
++ channel = NULL; |
2524 |
++ if (!info->attrs[NCSI_ATTR_CHANNEL_ID]) { |
2525 |
++ /* Allow any channel */ |
2526 |
++ channel_id = NCSI_RESERVED_CHANNEL; |
2527 |
++ } else { |
2528 |
++ channel_id = nla_get_u32(info->attrs[NCSI_ATTR_CHANNEL_ID]); |
2529 |
++ NCSI_FOR_EACH_CHANNEL(package, nc) |
2530 |
++ if (nc->id == channel_id) |
2531 |
++ channel = nc; |
2532 |
++ } |
2533 |
++ |
2534 |
++ if (channel_id != NCSI_RESERVED_CHANNEL && !channel) { |
2535 |
++ /* The user has set a channel that does not exist on this |
2536 |
++ * package |
2537 |
++ */ |
2538 |
++ netdev_info(ndp->ndev.dev, "NCSI: Channel %u does not exist!\n", |
2539 |
++ channel_id); |
2540 |
++ return -ERANGE; |
2541 |
++ } |
2542 |
++ |
2543 |
++ ndp->force_package = package; |
2544 |
++ ndp->force_channel = channel; |
2545 |
++ spin_unlock_irqrestore(&ndp->lock, flags); |
2546 |
++ |
2547 |
++ netdev_info(ndp->ndev.dev, "Set package 0x%x, channel 0x%x%s as preferred\n", |
2548 |
++ package_id, channel_id, |
2549 |
++ channel_id == NCSI_RESERVED_CHANNEL ? " (any)" : ""); |
2550 |
++ |
2551 |
++ /* Bounce the NCSI channel to set changes */ |
2552 |
++ ncsi_stop_dev(&ndp->ndev); |
2553 |
++ ncsi_start_dev(&ndp->ndev); |
2554 |
++ |
2555 |
++ return 0; |
2556 |
++} |
2557 |
++ |
2558 |
++static int ncsi_clear_interface_nl(struct sk_buff *msg, struct genl_info *info) |
2559 |
++{ |
2560 |
++ struct ncsi_dev_priv *ndp; |
2561 |
++ unsigned long flags; |
2562 |
++ |
2563 |
++ if (!info || !info->attrs) |
2564 |
++ return -EINVAL; |
2565 |
++ |
2566 |
++ if (!info->attrs[NCSI_ATTR_IFINDEX]) |
2567 |
++ return -EINVAL; |
2568 |
++ |
2569 |
++ ndp = ndp_from_ifindex(get_net(sock_net(msg->sk)), |
2570 |
++ nla_get_u32(info->attrs[NCSI_ATTR_IFINDEX])); |
2571 |
++ if (!ndp) |
2572 |
++ return -ENODEV; |
2573 |
++ |
2574 |
++ /* Clear any override */ |
2575 |
++ spin_lock_irqsave(&ndp->lock, flags); |
2576 |
++ ndp->force_package = NULL; |
2577 |
++ ndp->force_channel = NULL; |
2578 |
++ spin_unlock_irqrestore(&ndp->lock, flags); |
2579 |
++ netdev_info(ndp->ndev.dev, "NCSI: Cleared preferred package/channel\n"); |
2580 |
++ |
2581 |
++ /* Bounce the NCSI channel to set changes */ |
2582 |
++ ncsi_stop_dev(&ndp->ndev); |
2583 |
++ ncsi_start_dev(&ndp->ndev); |
2584 |
++ |
2585 |
++ return 0; |
2586 |
++} |
2587 |
++ |
2588 |
++static const struct genl_ops ncsi_ops[] = { |
2589 |
++ { |
2590 |
++ .cmd = NCSI_CMD_PKG_INFO, |
2591 |
++ .policy = ncsi_genl_policy, |
2592 |
++ .doit = ncsi_pkg_info_nl, |
2593 |
++ .dumpit = ncsi_pkg_info_all_nl, |
2594 |
++ .flags = 0, |
2595 |
++ }, |
2596 |
++ { |
2597 |
++ .cmd = NCSI_CMD_SET_INTERFACE, |
2598 |
++ .policy = ncsi_genl_policy, |
2599 |
++ .doit = ncsi_set_interface_nl, |
2600 |
++ .flags = GENL_ADMIN_PERM, |
2601 |
++ }, |
2602 |
++ { |
2603 |
++ .cmd = NCSI_CMD_CLEAR_INTERFACE, |
2604 |
++ .policy = ncsi_genl_policy, |
2605 |
++ .doit = ncsi_clear_interface_nl, |
2606 |
++ .flags = GENL_ADMIN_PERM, |
2607 |
++ }, |
2608 |
++}; |
2609 |
++ |
2610 |
++static struct genl_family ncsi_genl_family __ro_after_init = { |
2611 |
++ .name = "NCSI", |
2612 |
++ .version = 0, |
2613 |
++ .maxattr = NCSI_ATTR_MAX, |
2614 |
++ .module = THIS_MODULE, |
2615 |
++ .ops = ncsi_ops, |
2616 |
++ .n_ops = ARRAY_SIZE(ncsi_ops), |
2617 |
++}; |
2618 |
++ |
2619 |
++int ncsi_init_netlink(struct net_device *dev) |
2620 |
++{ |
2621 |
++ int rc; |
2622 |
++ |
2623 |
++ rc = genl_register_family(&ncsi_genl_family); |
2624 |
++ if (rc) |
2625 |
++ netdev_err(dev, "ncsi: failed to register netlink family\n"); |
2626 |
++ |
2627 |
++ return rc; |
2628 |
++} |
2629 |
++ |
2630 |
++int ncsi_unregister_netlink(struct net_device *dev) |
2631 |
++{ |
2632 |
++ int rc; |
2633 |
++ |
2634 |
++ rc = genl_unregister_family(&ncsi_genl_family); |
2635 |
++ if (rc) |
2636 |
++ netdev_err(dev, "ncsi: failed to unregister netlink family\n"); |
2637 |
++ |
2638 |
++ return rc; |
2639 |
++} |
2640 |
+diff --git a/net/ncsi/ncsi-netlink.h b/net/ncsi/ncsi-netlink.h |
2641 |
+new file mode 100644 |
2642 |
+index 0000000000000..91a5c256f8c4f |
2643 |
+--- /dev/null |
2644 |
++++ b/net/ncsi/ncsi-netlink.h |
2645 |
+@@ -0,0 +1,20 @@ |
2646 |
++/* |
2647 |
++ * Copyright Samuel Mendoza-Jonas, IBM Corporation 2018. |
2648 |
++ * |
2649 |
++ * This program is free software; you can redistribute it and/or modify |
2650 |
++ * it under the terms of the GNU General Public License as published by |
2651 |
++ * the Free Software Foundation; either version 2 of the License, or |
2652 |
++ * (at your option) any later version. |
2653 |
++ */ |
2654 |
++ |
2655 |
++#ifndef __NCSI_NETLINK_H__ |
2656 |
++#define __NCSI_NETLINK_H__ |
2657 |
++ |
2658 |
++#include <linux/netdevice.h> |
2659 |
++ |
2660 |
++#include "internal.h" |
2661 |
++ |
2662 |
++int ncsi_init_netlink(struct net_device *dev); |
2663 |
++int ncsi_unregister_netlink(struct net_device *dev); |
2664 |
++ |
2665 |
++#endif /* __NCSI_NETLINK_H__ */ |
2666 |
+diff --git a/net/ncsi/ncsi-rsp.c b/net/ncsi/ncsi-rsp.c |
2667 |
+index bbedcf48d71c2..42878d843c3c3 100644 |
2668 |
+--- a/net/ncsi/ncsi-rsp.c |
2669 |
++++ b/net/ncsi/ncsi-rsp.c |
2670 |
+@@ -146,7 +146,7 @@ static int ncsi_rsp_handler_ec(struct ncsi_request *nr) |
2671 |
+ |
2672 |
+ ncm = &nc->modes[NCSI_MODE_ENABLE]; |
2673 |
+ if (ncm->enable) |
2674 |
+- return -EBUSY; |
2675 |
++ return 0; |
2676 |
+ |
2677 |
+ ncm->enable = 1; |
2678 |
+ return 0; |
2679 |
+@@ -173,7 +173,7 @@ static int ncsi_rsp_handler_dc(struct ncsi_request *nr) |
2680 |
+ |
2681 |
+ ncm = &nc->modes[NCSI_MODE_ENABLE]; |
2682 |
+ if (!ncm->enable) |
2683 |
+- return -EBUSY; |
2684 |
++ return 0; |
2685 |
+ |
2686 |
+ ncm->enable = 0; |
2687 |
+ return 0; |
2688 |
+@@ -217,7 +217,7 @@ static int ncsi_rsp_handler_ecnt(struct ncsi_request *nr) |
2689 |
+ |
2690 |
+ ncm = &nc->modes[NCSI_MODE_TX_ENABLE]; |
2691 |
+ if (ncm->enable) |
2692 |
+- return -EBUSY; |
2693 |
++ return 0; |
2694 |
+ |
2695 |
+ ncm->enable = 1; |
2696 |
+ return 0; |
2697 |
+@@ -239,7 +239,7 @@ static int ncsi_rsp_handler_dcnt(struct ncsi_request *nr) |
2698 |
+ |
2699 |
+ ncm = &nc->modes[NCSI_MODE_TX_ENABLE]; |
2700 |
+ if (!ncm->enable) |
2701 |
+- return -EBUSY; |
2702 |
++ return 0; |
2703 |
+ |
2704 |
+ ncm->enable = 1; |
2705 |
+ return 0; |
2706 |
+@@ -263,7 +263,7 @@ static int ncsi_rsp_handler_ae(struct ncsi_request *nr) |
2707 |
+ /* Check if the AEN has been enabled */ |
2708 |
+ ncm = &nc->modes[NCSI_MODE_AEN]; |
2709 |
+ if (ncm->enable) |
2710 |
+- return -EBUSY; |
2711 |
++ return 0; |
2712 |
+ |
2713 |
+ /* Update to AEN configuration */ |
2714 |
+ cmd = (struct ncsi_cmd_ae_pkt *)skb_network_header(nr->cmd); |
2715 |
+@@ -334,9 +334,9 @@ static int ncsi_rsp_handler_svf(struct ncsi_request *nr) |
2716 |
+ struct ncsi_rsp_pkt *rsp; |
2717 |
+ struct ncsi_dev_priv *ndp = nr->ndp; |
2718 |
+ struct ncsi_channel *nc; |
2719 |
+- struct ncsi_channel_filter *ncf; |
2720 |
+- unsigned short vlan; |
2721 |
+- int ret; |
2722 |
++ struct ncsi_channel_vlan_filter *ncf; |
2723 |
++ unsigned long flags; |
2724 |
++ void *bitmap; |
2725 |
+ |
2726 |
+ /* Find the package and channel */ |
2727 |
+ rsp = (struct ncsi_rsp_pkt *)skb_network_header(nr->rsp); |
2728 |
+@@ -346,22 +346,23 @@ static int ncsi_rsp_handler_svf(struct ncsi_request *nr) |
2729 |
+ return -ENODEV; |
2730 |
+ |
2731 |
+ cmd = (struct ncsi_cmd_svf_pkt *)skb_network_header(nr->cmd); |
2732 |
+- ncf = nc->filters[NCSI_FILTER_VLAN]; |
2733 |
+- if (!ncf) |
2734 |
+- return -ENOENT; |
2735 |
+- if (cmd->index >= ncf->total) |
2736 |
++ ncf = &nc->vlan_filter; |
2737 |
++ if (cmd->index > ncf->n_vids) |
2738 |
+ return -ERANGE; |
2739 |
+ |
2740 |
+- /* Add or remove the VLAN filter */ |
2741 |
++ /* Add or remove the VLAN filter. Remember HW indexes from 1 */ |
2742 |
++ spin_lock_irqsave(&nc->lock, flags); |
2743 |
++ bitmap = &ncf->bitmap; |
2744 |
+ if (!(cmd->enable & 0x1)) { |
2745 |
+- /* HW indexes from 1 */ |
2746 |
+- ret = ncsi_remove_filter(nc, NCSI_FILTER_VLAN, cmd->index - 1); |
2747 |
++ if (test_and_clear_bit(cmd->index - 1, bitmap)) |
2748 |
++ ncf->vids[cmd->index - 1] = 0; |
2749 |
+ } else { |
2750 |
+- vlan = ntohs(cmd->vlan); |
2751 |
+- ret = ncsi_add_filter(nc, NCSI_FILTER_VLAN, &vlan); |
2752 |
++ set_bit(cmd->index - 1, bitmap); |
2753 |
++ ncf->vids[cmd->index - 1] = ntohs(cmd->vlan); |
2754 |
+ } |
2755 |
++ spin_unlock_irqrestore(&nc->lock, flags); |
2756 |
+ |
2757 |
+- return ret; |
2758 |
++ return 0; |
2759 |
+ } |
2760 |
+ |
2761 |
+ static int ncsi_rsp_handler_ev(struct ncsi_request *nr) |
2762 |
+@@ -382,7 +383,7 @@ static int ncsi_rsp_handler_ev(struct ncsi_request *nr) |
2763 |
+ /* Check if VLAN mode has been enabled */ |
2764 |
+ ncm = &nc->modes[NCSI_MODE_VLAN]; |
2765 |
+ if (ncm->enable) |
2766 |
+- return -EBUSY; |
2767 |
++ return 0; |
2768 |
+ |
2769 |
+ /* Update to VLAN mode */ |
2770 |
+ cmd = (struct ncsi_cmd_ev_pkt *)skb_network_header(nr->cmd); |
2771 |
+@@ -409,7 +410,7 @@ static int ncsi_rsp_handler_dv(struct ncsi_request *nr) |
2772 |
+ /* Check if VLAN mode has been enabled */ |
2773 |
+ ncm = &nc->modes[NCSI_MODE_VLAN]; |
2774 |
+ if (!ncm->enable) |
2775 |
+- return -EBUSY; |
2776 |
++ return 0; |
2777 |
+ |
2778 |
+ /* Update to VLAN mode */ |
2779 |
+ ncm->enable = 0; |
2780 |
+@@ -422,8 +423,12 @@ static int ncsi_rsp_handler_sma(struct ncsi_request *nr) |
2781 |
+ struct ncsi_rsp_pkt *rsp; |
2782 |
+ struct ncsi_dev_priv *ndp = nr->ndp; |
2783 |
+ struct ncsi_channel *nc; |
2784 |
+- struct ncsi_channel_filter *ncf; |
2785 |
++ struct ncsi_channel_mac_filter *ncf; |
2786 |
++ unsigned long flags; |
2787 |
+ void *bitmap; |
2788 |
++ bool enabled; |
2789 |
++ int index; |
2790 |
++ |
2791 |
+ |
2792 |
+ /* Find the package and channel */ |
2793 |
+ rsp = (struct ncsi_rsp_pkt *)skb_network_header(nr->rsp); |
2794 |
+@@ -436,34 +441,23 @@ static int ncsi_rsp_handler_sma(struct ncsi_request *nr) |
2795 |
+ * isn't supported yet. |
2796 |
+ */ |
2797 |
+ cmd = (struct ncsi_cmd_sma_pkt *)skb_network_header(nr->cmd); |
2798 |
+- switch (cmd->at_e >> 5) { |
2799 |
+- case 0x0: /* UC address */ |
2800 |
+- ncf = nc->filters[NCSI_FILTER_UC]; |
2801 |
+- break; |
2802 |
+- case 0x1: /* MC address */ |
2803 |
+- ncf = nc->filters[NCSI_FILTER_MC]; |
2804 |
+- break; |
2805 |
+- default: |
2806 |
+- return -EINVAL; |
2807 |
+- } |
2808 |
++ enabled = cmd->at_e & 0x1; |
2809 |
++ ncf = &nc->mac_filter; |
2810 |
++ bitmap = &ncf->bitmap; |
2811 |
+ |
2812 |
+- /* Sanity check on the filter */ |
2813 |
+- if (!ncf) |
2814 |
+- return -ENOENT; |
2815 |
+- else if (cmd->index >= ncf->total) |
2816 |
++ if (cmd->index > ncf->n_uc + ncf->n_mc + ncf->n_mixed) |
2817 |
+ return -ERANGE; |
2818 |
+ |
2819 |
+- bitmap = &ncf->bitmap; |
2820 |
+- if (cmd->at_e & 0x1) { |
2821 |
+- if (test_and_set_bit(cmd->index, bitmap)) |
2822 |
+- return -EBUSY; |
2823 |
+- memcpy(ncf->data + 6 * cmd->index, cmd->mac, 6); |
2824 |
++ index = (cmd->index - 1) * ETH_ALEN; |
2825 |
++ spin_lock_irqsave(&nc->lock, flags); |
2826 |
++ if (enabled) { |
2827 |
++ set_bit(cmd->index - 1, bitmap); |
2828 |
++ memcpy(&ncf->addrs[index], cmd->mac, ETH_ALEN); |
2829 |
+ } else { |
2830 |
+- if (!test_and_clear_bit(cmd->index, bitmap)) |
2831 |
+- return -EBUSY; |
2832 |
+- |
2833 |
+- memset(ncf->data + 6 * cmd->index, 0, 6); |
2834 |
++ clear_bit(cmd->index - 1, bitmap); |
2835 |
++ memset(&ncf->addrs[index], 0, ETH_ALEN); |
2836 |
+ } |
2837 |
++ spin_unlock_irqrestore(&nc->lock, flags); |
2838 |
+ |
2839 |
+ return 0; |
2840 |
+ } |
2841 |
+@@ -485,7 +479,7 @@ static int ncsi_rsp_handler_ebf(struct ncsi_request *nr) |
2842 |
+ /* Check if broadcast filter has been enabled */ |
2843 |
+ ncm = &nc->modes[NCSI_MODE_BC]; |
2844 |
+ if (ncm->enable) |
2845 |
+- return -EBUSY; |
2846 |
++ return 0; |
2847 |
+ |
2848 |
+ /* Update to broadcast filter mode */ |
2849 |
+ cmd = (struct ncsi_cmd_ebf_pkt *)skb_network_header(nr->cmd); |
2850 |
+@@ -511,7 +505,7 @@ static int ncsi_rsp_handler_dbf(struct ncsi_request *nr) |
2851 |
+ /* Check if broadcast filter isn't enabled */ |
2852 |
+ ncm = &nc->modes[NCSI_MODE_BC]; |
2853 |
+ if (!ncm->enable) |
2854 |
+- return -EBUSY; |
2855 |
++ return 0; |
2856 |
+ |
2857 |
+ /* Update to broadcast filter mode */ |
2858 |
+ ncm->enable = 0; |
2859 |
+@@ -538,7 +532,7 @@ static int ncsi_rsp_handler_egmf(struct ncsi_request *nr) |
2860 |
+ /* Check if multicast filter has been enabled */ |
2861 |
+ ncm = &nc->modes[NCSI_MODE_MC]; |
2862 |
+ if (ncm->enable) |
2863 |
+- return -EBUSY; |
2864 |
++ return 0; |
2865 |
+ |
2866 |
+ /* Update to multicast filter mode */ |
2867 |
+ cmd = (struct ncsi_cmd_egmf_pkt *)skb_network_header(nr->cmd); |
2868 |
+@@ -564,7 +558,7 @@ static int ncsi_rsp_handler_dgmf(struct ncsi_request *nr) |
2869 |
+ /* Check if multicast filter has been enabled */ |
2870 |
+ ncm = &nc->modes[NCSI_MODE_MC]; |
2871 |
+ if (!ncm->enable) |
2872 |
+- return -EBUSY; |
2873 |
++ return 0; |
2874 |
+ |
2875 |
+ /* Update to multicast filter mode */ |
2876 |
+ ncm->enable = 0; |
2877 |
+@@ -591,7 +585,7 @@ static int ncsi_rsp_handler_snfc(struct ncsi_request *nr) |
2878 |
+ /* Check if flow control has been enabled */ |
2879 |
+ ncm = &nc->modes[NCSI_MODE_FC]; |
2880 |
+ if (ncm->enable) |
2881 |
+- return -EBUSY; |
2882 |
++ return 0; |
2883 |
+ |
2884 |
+ /* Update to flow control mode */ |
2885 |
+ cmd = (struct ncsi_cmd_snfc_pkt *)skb_network_header(nr->cmd); |
2886 |
+@@ -634,9 +628,7 @@ static int ncsi_rsp_handler_gc(struct ncsi_request *nr) |
2887 |
+ struct ncsi_rsp_gc_pkt *rsp; |
2888 |
+ struct ncsi_dev_priv *ndp = nr->ndp; |
2889 |
+ struct ncsi_channel *nc; |
2890 |
+- struct ncsi_channel_filter *ncf; |
2891 |
+- size_t size, entry_size; |
2892 |
+- int cnt, i; |
2893 |
++ size_t size; |
2894 |
+ |
2895 |
+ /* Find the channel */ |
2896 |
+ rsp = (struct ncsi_rsp_gc_pkt *)skb_network_header(nr->rsp); |
2897 |
+@@ -658,64 +650,40 @@ static int ncsi_rsp_handler_gc(struct ncsi_request *nr) |
2898 |
+ nc->caps[NCSI_CAP_VLAN].cap = rsp->vlan_mode & |
2899 |
+ NCSI_CAP_VLAN_MASK; |
2900 |
+ |
2901 |
+- /* Build filters */ |
2902 |
+- for (i = 0; i < NCSI_FILTER_MAX; i++) { |
2903 |
+- switch (i) { |
2904 |
+- case NCSI_FILTER_VLAN: |
2905 |
+- cnt = rsp->vlan_cnt; |
2906 |
+- entry_size = 2; |
2907 |
+- break; |
2908 |
+- case NCSI_FILTER_MIXED: |
2909 |
+- cnt = rsp->mixed_cnt; |
2910 |
+- entry_size = 6; |
2911 |
+- break; |
2912 |
+- case NCSI_FILTER_MC: |
2913 |
+- cnt = rsp->mc_cnt; |
2914 |
+- entry_size = 6; |
2915 |
+- break; |
2916 |
+- case NCSI_FILTER_UC: |
2917 |
+- cnt = rsp->uc_cnt; |
2918 |
+- entry_size = 6; |
2919 |
+- break; |
2920 |
+- default: |
2921 |
+- continue; |
2922 |
+- } |
2923 |
+- |
2924 |
+- if (!cnt || nc->filters[i]) |
2925 |
+- continue; |
2926 |
+- |
2927 |
+- size = sizeof(*ncf) + cnt * entry_size; |
2928 |
+- ncf = kzalloc(size, GFP_ATOMIC); |
2929 |
+- if (!ncf) { |
2930 |
+- pr_warn("%s: Cannot alloc filter table (%d)\n", |
2931 |
+- __func__, i); |
2932 |
+- return -ENOMEM; |
2933 |
+- } |
2934 |
+- |
2935 |
+- ncf->index = i; |
2936 |
+- ncf->total = cnt; |
2937 |
+- if (i == NCSI_FILTER_VLAN) { |
2938 |
+- /* Set VLAN filters active so they are cleared in |
2939 |
+- * first configuration state |
2940 |
+- */ |
2941 |
+- ncf->bitmap = U64_MAX; |
2942 |
+- } else { |
2943 |
+- ncf->bitmap = 0x0ul; |
2944 |
+- } |
2945 |
+- nc->filters[i] = ncf; |
2946 |
+- } |
2947 |
++ size = (rsp->uc_cnt + rsp->mc_cnt + rsp->mixed_cnt) * ETH_ALEN; |
2948 |
++ nc->mac_filter.addrs = kzalloc(size, GFP_ATOMIC); |
2949 |
++ if (!nc->mac_filter.addrs) |
2950 |
++ return -ENOMEM; |
2951 |
++ nc->mac_filter.n_uc = rsp->uc_cnt; |
2952 |
++ nc->mac_filter.n_mc = rsp->mc_cnt; |
2953 |
++ nc->mac_filter.n_mixed = rsp->mixed_cnt; |
2954 |
++ |
2955 |
++ nc->vlan_filter.vids = kcalloc(rsp->vlan_cnt, |
2956 |
++ sizeof(*nc->vlan_filter.vids), |
2957 |
++ GFP_ATOMIC); |
2958 |
++ if (!nc->vlan_filter.vids) |
2959 |
++ return -ENOMEM; |
2960 |
++ /* Set VLAN filters active so they are cleared in the first |
2961 |
++ * configuration state |
2962 |
++ */ |
2963 |
++ nc->vlan_filter.bitmap = U64_MAX; |
2964 |
++ nc->vlan_filter.n_vids = rsp->vlan_cnt; |
2965 |
+ |
2966 |
+ return 0; |
2967 |
+ } |
2968 |
+ |
2969 |
+ static int ncsi_rsp_handler_gp(struct ncsi_request *nr) |
2970 |
+ { |
2971 |
+- struct ncsi_rsp_gp_pkt *rsp; |
2972 |
++ struct ncsi_channel_vlan_filter *ncvf; |
2973 |
++ struct ncsi_channel_mac_filter *ncmf; |
2974 |
+ struct ncsi_dev_priv *ndp = nr->ndp; |
2975 |
++ struct ncsi_rsp_gp_pkt *rsp; |
2976 |
+ struct ncsi_channel *nc; |
2977 |
+- unsigned short enable, vlan; |
2978 |
++ unsigned short enable; |
2979 |
+ unsigned char *pdata; |
2980 |
+- int table, i; |
2981 |
++ unsigned long flags; |
2982 |
++ void *bitmap; |
2983 |
++ int i; |
2984 |
+ |
2985 |
+ /* Find the channel */ |
2986 |
+ rsp = (struct ncsi_rsp_gp_pkt *)skb_network_header(nr->rsp); |
2987 |
+@@ -749,36 +717,33 @@ static int ncsi_rsp_handler_gp(struct ncsi_request *nr) |
2988 |
+ /* MAC addresses filter table */ |
2989 |
+ pdata = (unsigned char *)rsp + 48; |
2990 |
+ enable = rsp->mac_enable; |
2991 |
++ ncmf = &nc->mac_filter; |
2992 |
++ spin_lock_irqsave(&nc->lock, flags); |
2993 |
++ bitmap = &ncmf->bitmap; |
2994 |
+ for (i = 0; i < rsp->mac_cnt; i++, pdata += 6) { |
2995 |
+- if (i >= (nc->filters[NCSI_FILTER_UC]->total + |
2996 |
+- nc->filters[NCSI_FILTER_MC]->total)) |
2997 |
+- table = NCSI_FILTER_MIXED; |
2998 |
+- else if (i >= nc->filters[NCSI_FILTER_UC]->total) |
2999 |
+- table = NCSI_FILTER_MC; |
3000 |
+- else |
3001 |
+- table = NCSI_FILTER_UC; |
3002 |
+- |
3003 |
+ if (!(enable & (0x1 << i))) |
3004 |
+- continue; |
3005 |
+- |
3006 |
+- if (ncsi_find_filter(nc, table, pdata) >= 0) |
3007 |
+- continue; |
3008 |
++ clear_bit(i, bitmap); |
3009 |
++ else |
3010 |
++ set_bit(i, bitmap); |
3011 |
+ |
3012 |
+- ncsi_add_filter(nc, table, pdata); |
3013 |
++ memcpy(&ncmf->addrs[i * ETH_ALEN], pdata, ETH_ALEN); |
3014 |
+ } |
3015 |
++ spin_unlock_irqrestore(&nc->lock, flags); |
3016 |
+ |
3017 |
+ /* VLAN filter table */ |
3018 |
+ enable = ntohs(rsp->vlan_enable); |
3019 |
++ ncvf = &nc->vlan_filter; |
3020 |
++ bitmap = &ncvf->bitmap; |
3021 |
++ spin_lock_irqsave(&nc->lock, flags); |
3022 |
+ for (i = 0; i < rsp->vlan_cnt; i++, pdata += 2) { |
3023 |
+ if (!(enable & (0x1 << i))) |
3024 |
+- continue; |
3025 |
+- |
3026 |
+- vlan = ntohs(*(__be16 *)pdata); |
3027 |
+- if (ncsi_find_filter(nc, NCSI_FILTER_VLAN, &vlan) >= 0) |
3028 |
+- continue; |
3029 |
++ clear_bit(i, bitmap); |
3030 |
++ else |
3031 |
++ set_bit(i, bitmap); |
3032 |
+ |
3033 |
+- ncsi_add_filter(nc, NCSI_FILTER_VLAN, &vlan); |
3034 |
++ ncvf->vids[i] = ntohs(*(__be16 *)pdata); |
3035 |
+ } |
3036 |
++ spin_unlock_irqrestore(&nc->lock, flags); |
3037 |
+ |
3038 |
+ return 0; |
3039 |
+ } |
3040 |
+@@ -1032,11 +997,19 @@ int ncsi_rcv_rsp(struct sk_buff *skb, struct net_device *dev, |
3041 |
+ if (payload < 0) |
3042 |
+ payload = ntohs(hdr->length); |
3043 |
+ ret = ncsi_validate_rsp_pkt(nr, payload); |
3044 |
+- if (ret) |
3045 |
++ if (ret) { |
3046 |
++ netdev_warn(ndp->ndev.dev, |
3047 |
++ "NCSI: 'bad' packet ignored for type 0x%x\n", |
3048 |
++ hdr->type); |
3049 |
+ goto out; |
3050 |
++ } |
3051 |
+ |
3052 |
+ /* Process the packet */ |
3053 |
+ ret = nrh->handler(nr); |
3054 |
++ if (ret) |
3055 |
++ netdev_err(ndp->ndev.dev, |
3056 |
++ "NCSI: Handler for packet type 0x%x returned %d\n", |
3057 |
++ hdr->type, ret); |
3058 |
+ out: |
3059 |
+ ncsi_free_request(nr); |
3060 |
+ return ret; |
3061 |
+diff --git a/net/netfilter/x_tables.c b/net/netfilter/x_tables.c |
3062 |
+index 43a22968e8664..e1b1e6a0f8878 100644 |
3063 |
+--- a/net/netfilter/x_tables.c |
3064 |
++++ b/net/netfilter/x_tables.c |
3065 |
+@@ -638,7 +638,7 @@ void xt_compat_match_from_user(struct xt_entry_match *m, void **dstptr, |
3066 |
+ { |
3067 |
+ const struct xt_match *match = m->u.kernel.match; |
3068 |
+ struct compat_xt_entry_match *cm = (struct compat_xt_entry_match *)m; |
3069 |
+- int pad, off = xt_compat_match_offset(match); |
3070 |
++ int off = xt_compat_match_offset(match); |
3071 |
+ u_int16_t msize = cm->u.user.match_size; |
3072 |
+ char name[sizeof(m->u.user.name)]; |
3073 |
+ |
3074 |
+@@ -648,9 +648,6 @@ void xt_compat_match_from_user(struct xt_entry_match *m, void **dstptr, |
3075 |
+ match->compat_from_user(m->data, cm->data); |
3076 |
+ else |
3077 |
+ memcpy(m->data, cm->data, msize - sizeof(*cm)); |
3078 |
+- pad = XT_ALIGN(match->matchsize) - match->matchsize; |
3079 |
+- if (pad > 0) |
3080 |
+- memset(m->data + match->matchsize, 0, pad); |
3081 |
+ |
3082 |
+ msize += off; |
3083 |
+ m->u.user.match_size = msize; |
3084 |
+@@ -993,7 +990,7 @@ void xt_compat_target_from_user(struct xt_entry_target *t, void **dstptr, |
3085 |
+ { |
3086 |
+ const struct xt_target *target = t->u.kernel.target; |
3087 |
+ struct compat_xt_entry_target *ct = (struct compat_xt_entry_target *)t; |
3088 |
+- int pad, off = xt_compat_target_offset(target); |
3089 |
++ int off = xt_compat_target_offset(target); |
3090 |
+ u_int16_t tsize = ct->u.user.target_size; |
3091 |
+ char name[sizeof(t->u.user.name)]; |
3092 |
+ |
3093 |
+@@ -1003,9 +1000,6 @@ void xt_compat_target_from_user(struct xt_entry_target *t, void **dstptr, |
3094 |
+ target->compat_from_user(t->data, ct->data); |
3095 |
+ else |
3096 |
+ memcpy(t->data, ct->data, tsize - sizeof(*ct)); |
3097 |
+- pad = XT_ALIGN(target->targetsize) - target->targetsize; |
3098 |
+- if (pad > 0) |
3099 |
+- memset(t->data + target->targetsize, 0, pad); |
3100 |
+ |
3101 |
+ tsize += off; |
3102 |
+ t->u.user.target_size = tsize; |
3103 |
+diff --git a/net/nfc/llcp_sock.c b/net/nfc/llcp_sock.c |
3104 |
+index 694a43c05eb9b..0c2c88a2f0b05 100644 |
3105 |
+--- a/net/nfc/llcp_sock.c |
3106 |
++++ b/net/nfc/llcp_sock.c |
3107 |
+@@ -120,11 +120,13 @@ static int llcp_sock_bind(struct socket *sock, struct sockaddr *addr, int alen) |
3108 |
+ llcp_sock->service_name_len, |
3109 |
+ GFP_KERNEL); |
3110 |
+ if (!llcp_sock->service_name) { |
3111 |
++ nfc_llcp_local_put(llcp_sock->local); |
3112 |
+ ret = -ENOMEM; |
3113 |
+ goto put_dev; |
3114 |
+ } |
3115 |
+ llcp_sock->ssap = nfc_llcp_get_sdp_ssap(local, llcp_sock); |
3116 |
+ if (llcp_sock->ssap == LLCP_SAP_MAX) { |
3117 |
++ nfc_llcp_local_put(llcp_sock->local); |
3118 |
+ kfree(llcp_sock->service_name); |
3119 |
+ llcp_sock->service_name = NULL; |
3120 |
+ ret = -EADDRINUSE; |
3121 |
+@@ -684,6 +686,10 @@ static int llcp_sock_connect(struct socket *sock, struct sockaddr *_addr, |
3122 |
+ ret = -EISCONN; |
3123 |
+ goto error; |
3124 |
+ } |
3125 |
++ if (sk->sk_state == LLCP_CONNECTING) { |
3126 |
++ ret = -EINPROGRESS; |
3127 |
++ goto error; |
3128 |
++ } |
3129 |
+ |
3130 |
+ dev = nfc_get_device(addr->dev_idx); |
3131 |
+ if (dev == NULL) { |
3132 |
+@@ -715,6 +721,7 @@ static int llcp_sock_connect(struct socket *sock, struct sockaddr *_addr, |
3133 |
+ llcp_sock->local = nfc_llcp_local_get(local); |
3134 |
+ llcp_sock->ssap = nfc_llcp_get_local_ssap(local); |
3135 |
+ if (llcp_sock->ssap == LLCP_SAP_MAX) { |
3136 |
++ nfc_llcp_local_put(llcp_sock->local); |
3137 |
+ ret = -ENOMEM; |
3138 |
+ goto put_dev; |
3139 |
+ } |
3140 |
+@@ -752,8 +759,11 @@ static int llcp_sock_connect(struct socket *sock, struct sockaddr *_addr, |
3141 |
+ |
3142 |
+ sock_unlink: |
3143 |
+ nfc_llcp_put_ssap(local, llcp_sock->ssap); |
3144 |
++ nfc_llcp_local_put(llcp_sock->local); |
3145 |
+ |
3146 |
+ nfc_llcp_sock_unlink(&local->connecting_sockets, sk); |
3147 |
++ kfree(llcp_sock->service_name); |
3148 |
++ llcp_sock->service_name = NULL; |
3149 |
+ |
3150 |
+ put_dev: |
3151 |
+ nfc_put_device(dev); |
3152 |
+diff --git a/net/sched/sch_teql.c b/net/sched/sch_teql.c |
3153 |
+index 9fe6b427afed0..5d8c095ec5eca 100644 |
3154 |
+--- a/net/sched/sch_teql.c |
3155 |
++++ b/net/sched/sch_teql.c |
3156 |
+@@ -138,6 +138,9 @@ teql_destroy(struct Qdisc *sch) |
3157 |
+ struct teql_sched_data *dat = qdisc_priv(sch); |
3158 |
+ struct teql_master *master = dat->m; |
3159 |
+ |
3160 |
++ if (!master) |
3161 |
++ return; |
3162 |
++ |
3163 |
+ prev = master->slaves; |
3164 |
+ if (prev) { |
3165 |
+ do { |
3166 |
+diff --git a/net/tipc/socket.c b/net/tipc/socket.c |
3167 |
+index 44ede9ab78985..6fd5e1a7a336e 100644 |
3168 |
+--- a/net/tipc/socket.c |
3169 |
++++ b/net/tipc/socket.c |
3170 |
+@@ -840,7 +840,7 @@ void tipc_sk_mcast_rcv(struct net *net, struct sk_buff_head *arrvq, |
3171 |
+ spin_lock_bh(&inputq->lock); |
3172 |
+ if (skb_peek(arrvq) == skb) { |
3173 |
+ skb_queue_splice_tail_init(&tmpq, inputq); |
3174 |
+- kfree_skb(__skb_dequeue(arrvq)); |
3175 |
++ __skb_dequeue(arrvq); |
3176 |
+ } |
3177 |
+ spin_unlock_bh(&inputq->lock); |
3178 |
+ __skb_queue_purge(&tmpq); |
3179 |
+diff --git a/net/wireless/sme.c b/net/wireless/sme.c |
3180 |
+index 8344153800e27..c9158360154a4 100644 |
3181 |
+--- a/net/wireless/sme.c |
3182 |
++++ b/net/wireless/sme.c |
3183 |
+@@ -530,7 +530,7 @@ static int cfg80211_sme_connect(struct wireless_dev *wdev, |
3184 |
+ cfg80211_sme_free(wdev); |
3185 |
+ } |
3186 |
+ |
3187 |
+- if (WARN_ON(wdev->conn)) |
3188 |
++ if (wdev->conn) |
3189 |
+ return -EINPROGRESS; |
3190 |
+ |
3191 |
+ wdev->conn = kzalloc(sizeof(*wdev->conn), GFP_KERNEL); |
3192 |
+diff --git a/sound/drivers/aloop.c b/sound/drivers/aloop.c |
3193 |
+index dfd30a80ece8e..8a32a276bd705 100644 |
3194 |
+--- a/sound/drivers/aloop.c |
3195 |
++++ b/sound/drivers/aloop.c |
3196 |
+@@ -1062,6 +1062,14 @@ static int loopback_mixer_new(struct loopback *loopback, int notify) |
3197 |
+ return -ENOMEM; |
3198 |
+ kctl->id.device = dev; |
3199 |
+ kctl->id.subdevice = substr; |
3200 |
++ |
3201 |
++ /* Add the control before copying the id so that |
3202 |
++ * the numid field of the id is set in the copy. |
3203 |
++ */ |
3204 |
++ err = snd_ctl_add(card, kctl); |
3205 |
++ if (err < 0) |
3206 |
++ return err; |
3207 |
++ |
3208 |
+ switch (idx) { |
3209 |
+ case ACTIVE_IDX: |
3210 |
+ setup->active_id = kctl->id; |
3211 |
+@@ -1078,9 +1086,6 @@ static int loopback_mixer_new(struct loopback *loopback, int notify) |
3212 |
+ default: |
3213 |
+ break; |
3214 |
+ } |
3215 |
+- err = snd_ctl_add(card, kctl); |
3216 |
+- if (err < 0) |
3217 |
+- return err; |
3218 |
+ } |
3219 |
+ } |
3220 |
+ } |
3221 |
+diff --git a/sound/soc/codecs/wm8960.c b/sound/soc/codecs/wm8960.c |
3222 |
+index 9ed4557009542..228ab7bd314d6 100644 |
3223 |
+--- a/sound/soc/codecs/wm8960.c |
3224 |
++++ b/sound/soc/codecs/wm8960.c |
3225 |
+@@ -710,7 +710,13 @@ int wm8960_configure_pll(struct snd_soc_codec *codec, int freq_in, |
3226 |
+ best_freq_out = -EINVAL; |
3227 |
+ *sysclk_idx = *dac_idx = *bclk_idx = -1; |
3228 |
+ |
3229 |
+- for (i = 0; i < ARRAY_SIZE(sysclk_divs); ++i) { |
3230 |
++ /* |
3231 |
++ * From Datasheet, the PLL performs best when f2 is between |
3232 |
++ * 90MHz and 100MHz, the desired sysclk output is 11.2896MHz |
3233 |
++ * or 12.288MHz, then sysclkdiv = 2 is the best choice. |
3234 |
++ * So search sysclk_divs from 2 to 1 other than from 1 to 2. |
3235 |
++ */ |
3236 |
++ for (i = ARRAY_SIZE(sysclk_divs) - 1; i >= 0; --i) { |
3237 |
+ if (sysclk_divs[i] == -1) |
3238 |
+ continue; |
3239 |
+ for (j = 0; j < ARRAY_SIZE(dac_divs); ++j) { |
3240 |
+diff --git a/sound/soc/intel/atom/sst-mfld-platform-pcm.c b/sound/soc/intel/atom/sst-mfld-platform-pcm.c |
3241 |
+index 3a645fc425cd4..cdc0f22a57ee3 100644 |
3242 |
+--- a/sound/soc/intel/atom/sst-mfld-platform-pcm.c |
3243 |
++++ b/sound/soc/intel/atom/sst-mfld-platform-pcm.c |
3244 |
+@@ -508,14 +508,14 @@ static struct snd_soc_dai_driver sst_platform_dai[] = { |
3245 |
+ .channels_min = SST_STEREO, |
3246 |
+ .channels_max = SST_STEREO, |
3247 |
+ .rates = SNDRV_PCM_RATE_44100|SNDRV_PCM_RATE_48000, |
3248 |
+- .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE, |
3249 |
++ .formats = SNDRV_PCM_FMTBIT_S16_LE, |
3250 |
+ }, |
3251 |
+ .capture = { |
3252 |
+ .stream_name = "Headset Capture", |
3253 |
+ .channels_min = 1, |
3254 |
+ .channels_max = 2, |
3255 |
+ .rates = SNDRV_PCM_RATE_44100|SNDRV_PCM_RATE_48000, |
3256 |
+- .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE, |
3257 |
++ .formats = SNDRV_PCM_FMTBIT_S16_LE, |
3258 |
+ }, |
3259 |
+ }, |
3260 |
+ { |
3261 |
+@@ -526,7 +526,7 @@ static struct snd_soc_dai_driver sst_platform_dai[] = { |
3262 |
+ .channels_min = SST_STEREO, |
3263 |
+ .channels_max = SST_STEREO, |
3264 |
+ .rates = SNDRV_PCM_RATE_44100|SNDRV_PCM_RATE_48000, |
3265 |
+- .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE, |
3266 |
++ .formats = SNDRV_PCM_FMTBIT_S16_LE, |
3267 |
+ }, |
3268 |
+ }, |
3269 |
+ { |
3270 |
+diff --git a/sound/soc/sunxi/sun4i-codec.c b/sound/soc/sunxi/sun4i-codec.c |
3271 |
+index baa9007464ed7..700779ca82d01 100644 |
3272 |
+--- a/sound/soc/sunxi/sun4i-codec.c |
3273 |
++++ b/sound/soc/sunxi/sun4i-codec.c |
3274 |
+@@ -1199,6 +1199,7 @@ static struct snd_soc_card *sun4i_codec_create_card(struct device *dev) |
3275 |
+ return ERR_PTR(-ENOMEM); |
3276 |
+ |
3277 |
+ card->dev = dev; |
3278 |
++ card->owner = THIS_MODULE; |
3279 |
+ card->name = "sun4i-codec"; |
3280 |
+ card->dapm_widgets = sun4i_codec_card_dapm_widgets; |
3281 |
+ card->num_dapm_widgets = ARRAY_SIZE(sun4i_codec_card_dapm_widgets); |
3282 |
+@@ -1231,6 +1232,7 @@ static struct snd_soc_card *sun6i_codec_create_card(struct device *dev) |
3283 |
+ return ERR_PTR(-ENOMEM); |
3284 |
+ |
3285 |
+ card->dev = dev; |
3286 |
++ card->owner = THIS_MODULE; |
3287 |
+ card->name = "A31 Audio Codec"; |
3288 |
+ card->dapm_widgets = sun6i_codec_card_dapm_widgets; |
3289 |
+ card->num_dapm_widgets = ARRAY_SIZE(sun6i_codec_card_dapm_widgets); |
3290 |
+@@ -1284,6 +1286,7 @@ static struct snd_soc_card *sun8i_a23_codec_create_card(struct device *dev) |
3291 |
+ return ERR_PTR(-ENOMEM); |
3292 |
+ |
3293 |
+ card->dev = dev; |
3294 |
++ card->owner = THIS_MODULE; |
3295 |
+ card->name = "A23 Audio Codec"; |
3296 |
+ card->dapm_widgets = sun6i_codec_card_dapm_widgets; |
3297 |
+ card->num_dapm_widgets = ARRAY_SIZE(sun6i_codec_card_dapm_widgets); |
3298 |
+@@ -1322,6 +1325,7 @@ static struct snd_soc_card *sun8i_h3_codec_create_card(struct device *dev) |
3299 |
+ return ERR_PTR(-ENOMEM); |
3300 |
+ |
3301 |
+ card->dev = dev; |
3302 |
++ card->owner = THIS_MODULE; |
3303 |
+ card->name = "H3 Audio Codec"; |
3304 |
+ card->dapm_widgets = sun6i_codec_card_dapm_widgets; |
3305 |
+ card->num_dapm_widgets = ARRAY_SIZE(sun6i_codec_card_dapm_widgets); |
3306 |
+@@ -1360,6 +1364,7 @@ static struct snd_soc_card *sun8i_v3s_codec_create_card(struct device *dev) |
3307 |
+ return ERR_PTR(-ENOMEM); |
3308 |
+ |
3309 |
+ card->dev = dev; |
3310 |
++ card->owner = THIS_MODULE; |
3311 |
+ card->name = "V3s Audio Codec"; |
3312 |
+ card->dapm_widgets = sun6i_codec_card_dapm_widgets; |
3313 |
+ card->num_dapm_widgets = ARRAY_SIZE(sun6i_codec_card_dapm_widgets); |
3314 |
+diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c |
3315 |
+index a49f27aa0c95a..9d42a2821ecb9 100644 |
3316 |
+--- a/tools/perf/util/map.c |
3317 |
++++ b/tools/perf/util/map.c |
3318 |
+@@ -93,8 +93,7 @@ static inline bool replace_android_lib(const char *filename, char *newfilename) |
3319 |
+ if (!strncmp(filename, "/system/lib/", 12)) { |
3320 |
+ char *ndk, *app; |
3321 |
+ const char *arch; |
3322 |
+- size_t ndk_length; |
3323 |
+- size_t app_length; |
3324 |
++ int ndk_length, app_length; |
3325 |
+ |
3326 |
+ ndk = getenv("NDK_ROOT"); |
3327 |
+ app = getenv("APP_PLATFORM"); |
3328 |
+@@ -122,8 +121,8 @@ static inline bool replace_android_lib(const char *filename, char *newfilename) |
3329 |
+ if (new_length > PATH_MAX) |
3330 |
+ return false; |
3331 |
+ snprintf(newfilename, new_length, |
3332 |
+- "%s/platforms/%s/arch-%s/usr/lib/%s", |
3333 |
+- ndk, app, arch, libname); |
3334 |
++ "%.*s/platforms/%.*s/arch-%s/usr/lib/%s", |
3335 |
++ ndk_length, ndk, app_length, app, arch, libname); |
3336 |
+ |
3337 |
+ return true; |
3338 |
+ } |