diff options
author | David S. Miller <davem@davemloft.net> | 2015-05-04 15:36:07 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-05-04 15:36:07 -0400 |
commit | 73e84313ee4178cac628009103a901af9dfe8920 (patch) | |
tree | 6328e1f97e4757dcf59d99e97eb2b70b352e62da | |
parent | e2783717a71e9babfdd7c36c7e35b790d2c01022 (diff) | |
parent | 1add15646672ff4e7fe59bec2afcb5a0c80c5e49 (diff) |
Merge branch 'for-upstream' of git://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth-next
Johan Hedberg says:
====================
pull request: bluetooth-next 2015-05-04
Here's the first bluetooth-next pull request for 4.2:
- Various fixes for at86rf230 driver
- ieee802154: trace events support for rdev->ops
- HCI UART driver refactoring
- New Realtek IDs added to btusb driver
- Off-by-one fix for rtl8723b in btusb driver
- Refactoring of btbcm driver for both UART & USB use
Please let me know if there are any issues pulling. Thanks.
====================
Signed-off-by: David S. Miller <davem@davemloft.net>
30 files changed, 1308 insertions, 364 deletions
diff --git a/drivers/bluetooth/bt3c_cs.c b/drivers/bluetooth/bt3c_cs.c index 4f7e8d400bc0..6de97b3871b0 100644 --- a/drivers/bluetooth/bt3c_cs.c +++ b/drivers/bluetooth/bt3c_cs.c | |||
@@ -227,7 +227,6 @@ static void bt3c_receive(struct bt3c_info *info) | |||
227 | iobase = info->p_dev->resource[0]->start; | 227 | iobase = info->p_dev->resource[0]->start; |
228 | 228 | ||
229 | avail = bt3c_read(iobase, 0x7006); | 229 | avail = bt3c_read(iobase, 0x7006); |
230 | //printk("bt3c_cs: receiving %d bytes\n", avail); | ||
231 | 230 | ||
232 | bt3c_address(iobase, 0x7480); | 231 | bt3c_address(iobase, 0x7480); |
233 | while (size < avail) { | 232 | while (size < avail) { |
@@ -250,7 +249,6 @@ static void bt3c_receive(struct bt3c_info *info) | |||
250 | 249 | ||
251 | bt_cb(info->rx_skb)->pkt_type = inb(iobase + DATA_L); | 250 | bt_cb(info->rx_skb)->pkt_type = inb(iobase + DATA_L); |
252 | inb(iobase + DATA_H); | 251 | inb(iobase + DATA_H); |
253 | //printk("bt3c: PACKET_TYPE=%02x\n", bt_cb(info->rx_skb)->pkt_type); | ||
254 | 252 | ||
255 | switch (bt_cb(info->rx_skb)->pkt_type) { | 253 | switch (bt_cb(info->rx_skb)->pkt_type) { |
256 | 254 | ||
@@ -364,7 +362,6 @@ static irqreturn_t bt3c_interrupt(int irq, void *dev_inst) | |||
364 | if (stat & 0x0001) | 362 | if (stat & 0x0001) |
365 | bt3c_receive(info); | 363 | bt3c_receive(info); |
366 | if (stat & 0x0002) { | 364 | if (stat & 0x0002) { |
367 | //BT_ERR("Ack (stat=0x%04x)", stat); | ||
368 | clear_bit(XMIT_SENDING, &(info->tx_state)); | 365 | clear_bit(XMIT_SENDING, &(info->tx_state)); |
369 | bt3c_write_wakeup(info); | 366 | bt3c_write_wakeup(info); |
370 | } | 367 | } |
diff --git a/drivers/bluetooth/btbcm.c b/drivers/bluetooth/btbcm.c index d0741f3ed7ec..4bba86677adc 100644 --- a/drivers/bluetooth/btbcm.c +++ b/drivers/bluetooth/btbcm.c | |||
@@ -95,6 +95,78 @@ int btbcm_set_bdaddr(struct hci_dev *hdev, const bdaddr_t *bdaddr) | |||
95 | } | 95 | } |
96 | EXPORT_SYMBOL_GPL(btbcm_set_bdaddr); | 96 | EXPORT_SYMBOL_GPL(btbcm_set_bdaddr); |
97 | 97 | ||
98 | int btbcm_patchram(struct hci_dev *hdev, const char *firmware) | ||
99 | { | ||
100 | const struct hci_command_hdr *cmd; | ||
101 | const struct firmware *fw; | ||
102 | const u8 *fw_ptr; | ||
103 | size_t fw_size; | ||
104 | struct sk_buff *skb; | ||
105 | u16 opcode; | ||
106 | int err; | ||
107 | |||
108 | err = request_firmware(&fw, firmware, &hdev->dev); | ||
109 | if (err < 0) { | ||
110 | BT_INFO("%s: BCM: Patch %s not found", hdev->name, firmware); | ||
111 | return err; | ||
112 | } | ||
113 | |||
114 | /* Start Download */ | ||
115 | skb = __hci_cmd_sync(hdev, 0xfc2e, 0, NULL, HCI_INIT_TIMEOUT); | ||
116 | if (IS_ERR(skb)) { | ||
117 | err = PTR_ERR(skb); | ||
118 | BT_ERR("%s: BCM: Download Minidrv command failed (%d)", | ||
119 | hdev->name, err); | ||
120 | goto done; | ||
121 | } | ||
122 | kfree_skb(skb); | ||
123 | |||
124 | /* 50 msec delay after Download Minidrv completes */ | ||
125 | msleep(50); | ||
126 | |||
127 | fw_ptr = fw->data; | ||
128 | fw_size = fw->size; | ||
129 | |||
130 | while (fw_size >= sizeof(*cmd)) { | ||
131 | const u8 *cmd_param; | ||
132 | |||
133 | cmd = (struct hci_command_hdr *)fw_ptr; | ||
134 | fw_ptr += sizeof(*cmd); | ||
135 | fw_size -= sizeof(*cmd); | ||
136 | |||
137 | if (fw_size < cmd->plen) { | ||
138 | BT_ERR("%s: BCM: Patch %s is corrupted", hdev->name, | ||
139 | firmware); | ||
140 | err = -EINVAL; | ||
141 | goto done; | ||
142 | } | ||
143 | |||
144 | cmd_param = fw_ptr; | ||
145 | fw_ptr += cmd->plen; | ||
146 | fw_size -= cmd->plen; | ||
147 | |||
148 | opcode = le16_to_cpu(cmd->opcode); | ||
149 | |||
150 | skb = __hci_cmd_sync(hdev, opcode, cmd->plen, cmd_param, | ||
151 | HCI_INIT_TIMEOUT); | ||
152 | if (IS_ERR(skb)) { | ||
153 | err = PTR_ERR(skb); | ||
154 | BT_ERR("%s: BCM: Patch command %04x failed (%d)", | ||
155 | hdev->name, opcode, err); | ||
156 | goto done; | ||
157 | } | ||
158 | kfree_skb(skb); | ||
159 | } | ||
160 | |||
161 | /* 250 msec delay after Launch Ram completes */ | ||
162 | msleep(250); | ||
163 | |||
164 | done: | ||
165 | release_firmware(fw); | ||
166 | return err; | ||
167 | } | ||
168 | EXPORT_SYMBOL(btbcm_patchram); | ||
169 | |||
98 | static int btbcm_reset(struct hci_dev *hdev) | 170 | static int btbcm_reset(struct hci_dev *hdev) |
99 | { | 171 | { |
100 | struct sk_buff *skb; | 172 | struct sk_buff *skb; |
@@ -198,12 +270,8 @@ static const struct { | |||
198 | 270 | ||
199 | int btbcm_setup_patchram(struct hci_dev *hdev) | 271 | int btbcm_setup_patchram(struct hci_dev *hdev) |
200 | { | 272 | { |
201 | const struct hci_command_hdr *cmd; | ||
202 | const struct firmware *fw; | ||
203 | const u8 *fw_ptr; | ||
204 | size_t fw_size; | ||
205 | char fw_name[64]; | 273 | char fw_name[64]; |
206 | u16 opcode, subver, rev, pid, vid; | 274 | u16 subver, rev, pid, vid; |
207 | const char *hw_name = NULL; | 275 | const char *hw_name = NULL; |
208 | struct sk_buff *skb; | 276 | struct sk_buff *skb; |
209 | struct hci_rp_read_local_version *ver; | 277 | struct hci_rp_read_local_version *ver; |
@@ -273,74 +341,19 @@ int btbcm_setup_patchram(struct hci_dev *hdev) | |||
273 | hw_name ? : "BCM", (subver & 0x7000) >> 13, | 341 | hw_name ? : "BCM", (subver & 0x7000) >> 13, |
274 | (subver & 0x1f00) >> 8, (subver & 0x00ff), rev & 0x0fff); | 342 | (subver & 0x1f00) >> 8, (subver & 0x00ff), rev & 0x0fff); |
275 | 343 | ||
276 | err = request_firmware(&fw, fw_name, &hdev->dev); | 344 | err = btbcm_patchram(hdev, fw_name); |
277 | if (err < 0) { | 345 | if (err == -ENOENT) |
278 | BT_INFO("%s: BCM: patch %s not found", hdev->name, fw_name); | ||
279 | return 0; | 346 | return 0; |
280 | } | ||
281 | |||
282 | /* Start Download */ | ||
283 | skb = __hci_cmd_sync(hdev, 0xfc2e, 0, NULL, HCI_INIT_TIMEOUT); | ||
284 | if (IS_ERR(skb)) { | ||
285 | err = PTR_ERR(skb); | ||
286 | BT_ERR("%s: BCM: Download Minidrv command failed (%d)", | ||
287 | hdev->name, err); | ||
288 | goto reset; | ||
289 | } | ||
290 | kfree_skb(skb); | ||
291 | |||
292 | /* 50 msec delay after Download Minidrv completes */ | ||
293 | msleep(50); | ||
294 | |||
295 | fw_ptr = fw->data; | ||
296 | fw_size = fw->size; | ||
297 | |||
298 | while (fw_size >= sizeof(*cmd)) { | ||
299 | const u8 *cmd_param; | ||
300 | |||
301 | cmd = (struct hci_command_hdr *)fw_ptr; | ||
302 | fw_ptr += sizeof(*cmd); | ||
303 | fw_size -= sizeof(*cmd); | ||
304 | |||
305 | if (fw_size < cmd->plen) { | ||
306 | BT_ERR("%s: BCM: patch %s is corrupted", hdev->name, | ||
307 | fw_name); | ||
308 | err = -EINVAL; | ||
309 | goto reset; | ||
310 | } | ||
311 | 347 | ||
312 | cmd_param = fw_ptr; | ||
313 | fw_ptr += cmd->plen; | ||
314 | fw_size -= cmd->plen; | ||
315 | |||
316 | opcode = le16_to_cpu(cmd->opcode); | ||
317 | |||
318 | skb = __hci_cmd_sync(hdev, opcode, cmd->plen, cmd_param, | ||
319 | HCI_INIT_TIMEOUT); | ||
320 | if (IS_ERR(skb)) { | ||
321 | err = PTR_ERR(skb); | ||
322 | BT_ERR("%s: BCM: patch command %04x failed (%d)", | ||
323 | hdev->name, opcode, err); | ||
324 | goto reset; | ||
325 | } | ||
326 | kfree_skb(skb); | ||
327 | } | ||
328 | |||
329 | /* 250 msec delay after Launch Ram completes */ | ||
330 | msleep(250); | ||
331 | |||
332 | reset: | ||
333 | /* Reset */ | 348 | /* Reset */ |
334 | err = btbcm_reset(hdev); | 349 | err = btbcm_reset(hdev); |
335 | if (err) | 350 | if (err) |
336 | goto done; | 351 | return err; |
337 | 352 | ||
338 | /* Read Local Version Info */ | 353 | /* Read Local Version Info */ |
339 | skb = btbcm_read_local_version(hdev); | 354 | skb = btbcm_read_local_version(hdev); |
340 | if (IS_ERR(skb)) { | 355 | if (IS_ERR(skb)) |
341 | err = PTR_ERR(skb); | 356 | return PTR_ERR(skb); |
342 | goto done; | ||
343 | } | ||
344 | 357 | ||
345 | ver = (struct hci_rp_read_local_version *)skb->data; | 358 | ver = (struct hci_rp_read_local_version *)skb->data; |
346 | rev = le16_to_cpu(ver->hci_rev); | 359 | rev = le16_to_cpu(ver->hci_rev); |
@@ -355,10 +368,7 @@ reset: | |||
355 | 368 | ||
356 | set_bit(HCI_QUIRK_STRICT_DUPLICATE_FILTER, &hdev->quirks); | 369 | set_bit(HCI_QUIRK_STRICT_DUPLICATE_FILTER, &hdev->quirks); |
357 | 370 | ||
358 | done: | 371 | return 0; |
359 | release_firmware(fw); | ||
360 | |||
361 | return err; | ||
362 | } | 372 | } |
363 | EXPORT_SYMBOL_GPL(btbcm_setup_patchram); | 373 | EXPORT_SYMBOL_GPL(btbcm_setup_patchram); |
364 | 374 | ||
diff --git a/drivers/bluetooth/btbcm.h b/drivers/bluetooth/btbcm.h index 34268ae3eb46..eb6ab5f9483d 100644 --- a/drivers/bluetooth/btbcm.h +++ b/drivers/bluetooth/btbcm.h | |||
@@ -25,6 +25,7 @@ | |||
25 | 25 | ||
26 | int btbcm_check_bdaddr(struct hci_dev *hdev); | 26 | int btbcm_check_bdaddr(struct hci_dev *hdev); |
27 | int btbcm_set_bdaddr(struct hci_dev *hdev, const bdaddr_t *bdaddr); | 27 | int btbcm_set_bdaddr(struct hci_dev *hdev, const bdaddr_t *bdaddr); |
28 | int btbcm_patchram(struct hci_dev *hdev, const char *firmware); | ||
28 | 29 | ||
29 | int btbcm_setup_patchram(struct hci_dev *hdev); | 30 | int btbcm_setup_patchram(struct hci_dev *hdev); |
30 | int btbcm_setup_apple(struct hci_dev *hdev); | 31 | int btbcm_setup_apple(struct hci_dev *hdev); |
@@ -41,6 +42,11 @@ static inline int btbcm_set_bdaddr(struct hci_dev *hdev, const bdaddr_t *bdaddr) | |||
41 | return -EOPNOTSUPP; | 42 | return -EOPNOTSUPP; |
42 | } | 43 | } |
43 | 44 | ||
45 | static inline int btbcm_patchram(struct hci_dev *hdev, const char *firmware) | ||
46 | { | ||
47 | return -EOPNOTSUPP; | ||
48 | } | ||
49 | |||
44 | static inline int btbcm_setup_patchram(struct hci_dev *hdev) | 50 | static inline int btbcm_setup_patchram(struct hci_dev *hdev) |
45 | { | 51 | { |
46 | return 0; | 52 | return 0; |
diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c index de7b236eeae7..d21f3b4176d3 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c | |||
@@ -24,6 +24,7 @@ | |||
24 | #include <linux/module.h> | 24 | #include <linux/module.h> |
25 | #include <linux/usb.h> | 25 | #include <linux/usb.h> |
26 | #include <linux/firmware.h> | 26 | #include <linux/firmware.h> |
27 | #include <asm/unaligned.h> | ||
27 | 28 | ||
28 | #include <net/bluetooth/bluetooth.h> | 29 | #include <net/bluetooth/bluetooth.h> |
29 | #include <net/bluetooth/hci_core.h> | 30 | #include <net/bluetooth/hci_core.h> |
@@ -57,6 +58,7 @@ static struct usb_driver btusb_driver; | |||
57 | #define BTUSB_AMP 0x4000 | 58 | #define BTUSB_AMP 0x4000 |
58 | #define BTUSB_QCA_ROME 0x8000 | 59 | #define BTUSB_QCA_ROME 0x8000 |
59 | #define BTUSB_BCM_APPLE 0x10000 | 60 | #define BTUSB_BCM_APPLE 0x10000 |
61 | #define BTUSB_REALTEK 0x20000 | ||
60 | 62 | ||
61 | static const struct usb_device_id btusb_table[] = { | 63 | static const struct usb_device_id btusb_table[] = { |
62 | /* Generic Bluetooth USB device */ | 64 | /* Generic Bluetooth USB device */ |
@@ -288,6 +290,28 @@ static const struct usb_device_id blacklist_table[] = { | |||
288 | { USB_VENDOR_AND_INTERFACE_INFO(0x8087, 0xe0, 0x01, 0x01), | 290 | { USB_VENDOR_AND_INTERFACE_INFO(0x8087, 0xe0, 0x01, 0x01), |
289 | .driver_info = BTUSB_IGNORE }, | 291 | .driver_info = BTUSB_IGNORE }, |
290 | 292 | ||
293 | /* Realtek Bluetooth devices */ | ||
294 | { USB_VENDOR_AND_INTERFACE_INFO(0x0bda, 0xe0, 0x01, 0x01), | ||
295 | .driver_info = BTUSB_REALTEK }, | ||
296 | |||
297 | /* Additional Realtek 8723AE Bluetooth devices */ | ||
298 | { USB_DEVICE(0x0930, 0x021d), .driver_info = BTUSB_REALTEK }, | ||
299 | { USB_DEVICE(0x13d3, 0x3394), .driver_info = BTUSB_REALTEK }, | ||
300 | |||
301 | /* Additional Realtek 8723BE Bluetooth devices */ | ||
302 | { USB_DEVICE(0x0489, 0xe085), .driver_info = BTUSB_REALTEK }, | ||
303 | { USB_DEVICE(0x0489, 0xe08b), .driver_info = BTUSB_REALTEK }, | ||
304 | { USB_DEVICE(0x13d3, 0x3410), .driver_info = BTUSB_REALTEK }, | ||
305 | { USB_DEVICE(0x13d3, 0x3416), .driver_info = BTUSB_REALTEK }, | ||
306 | { USB_DEVICE(0x13d3, 0x3459), .driver_info = BTUSB_REALTEK }, | ||
307 | |||
308 | /* Additional Realtek 8821AE Bluetooth devices */ | ||
309 | { USB_DEVICE(0x0b05, 0x17dc), .driver_info = BTUSB_REALTEK }, | ||
310 | { USB_DEVICE(0x13d3, 0x3414), .driver_info = BTUSB_REALTEK }, | ||
311 | { USB_DEVICE(0x13d3, 0x3458), .driver_info = BTUSB_REALTEK }, | ||
312 | { USB_DEVICE(0x13d3, 0x3461), .driver_info = BTUSB_REALTEK }, | ||
313 | { USB_DEVICE(0x13d3, 0x3462), .driver_info = BTUSB_REALTEK }, | ||
314 | |||
291 | { } /* Terminating entry */ | 315 | { } /* Terminating entry */ |
292 | }; | 316 | }; |
293 | 317 | ||
@@ -892,7 +916,7 @@ static int btusb_open(struct hci_dev *hdev) | |||
892 | */ | 916 | */ |
893 | if (data->setup_on_usb) { | 917 | if (data->setup_on_usb) { |
894 | err = data->setup_on_usb(hdev); | 918 | err = data->setup_on_usb(hdev); |
895 | if (err <0) | 919 | if (err < 0) |
896 | return err; | 920 | return err; |
897 | } | 921 | } |
898 | 922 | ||
@@ -1345,6 +1369,378 @@ static int btusb_setup_csr(struct hci_dev *hdev) | |||
1345 | return ret; | 1369 | return ret; |
1346 | } | 1370 | } |
1347 | 1371 | ||
1372 | #define RTL_FRAG_LEN 252 | ||
1373 | |||
1374 | struct rtl_download_cmd { | ||
1375 | __u8 index; | ||
1376 | __u8 data[RTL_FRAG_LEN]; | ||
1377 | } __packed; | ||
1378 | |||
1379 | struct rtl_download_response { | ||
1380 | __u8 status; | ||
1381 | __u8 index; | ||
1382 | } __packed; | ||
1383 | |||
1384 | struct rtl_rom_version_evt { | ||
1385 | __u8 status; | ||
1386 | __u8 version; | ||
1387 | } __packed; | ||
1388 | |||
1389 | struct rtl_epatch_header { | ||
1390 | __u8 signature[8]; | ||
1391 | __le32 fw_version; | ||
1392 | __le16 num_patches; | ||
1393 | } __packed; | ||
1394 | |||
1395 | #define RTL_EPATCH_SIGNATURE "Realtech" | ||
1396 | #define RTL_ROM_LMP_3499 0x3499 | ||
1397 | #define RTL_ROM_LMP_8723A 0x1200 | ||
1398 | #define RTL_ROM_LMP_8723B 0x8723 | ||
1399 | #define RTL_ROM_LMP_8821A 0x8821 | ||
1400 | #define RTL_ROM_LMP_8761A 0x8761 | ||
1401 | |||
1402 | static int rtl_read_rom_version(struct hci_dev *hdev, u8 *version) | ||
1403 | { | ||
1404 | struct rtl_rom_version_evt *rom_version; | ||
1405 | struct sk_buff *skb; | ||
1406 | int ret; | ||
1407 | |||
1408 | /* Read RTL ROM version command */ | ||
1409 | skb = __hci_cmd_sync(hdev, 0xfc6d, 0, NULL, HCI_INIT_TIMEOUT); | ||
1410 | if (IS_ERR(skb)) { | ||
1411 | BT_ERR("%s: Read ROM version failed (%ld)", | ||
1412 | hdev->name, PTR_ERR(skb)); | ||
1413 | return PTR_ERR(skb); | ||
1414 | } | ||
1415 | |||
1416 | if (skb->len != sizeof(*rom_version)) { | ||
1417 | BT_ERR("%s: RTL version event length mismatch", hdev->name); | ||
1418 | kfree_skb(skb); | ||
1419 | return -EIO; | ||
1420 | } | ||
1421 | |||
1422 | rom_version = (struct rtl_rom_version_evt *)skb->data; | ||
1423 | BT_INFO("%s: rom_version status=%x version=%x", | ||
1424 | hdev->name, rom_version->status, rom_version->version); | ||
1425 | |||
1426 | ret = rom_version->status; | ||
1427 | if (ret == 0) | ||
1428 | *version = rom_version->version; | ||
1429 | |||
1430 | kfree_skb(skb); | ||
1431 | return ret; | ||
1432 | } | ||
1433 | |||
1434 | static int rtl8723b_parse_firmware(struct hci_dev *hdev, u16 lmp_subver, | ||
1435 | const struct firmware *fw, | ||
1436 | unsigned char **_buf) | ||
1437 | { | ||
1438 | const u8 extension_sig[] = { 0x51, 0x04, 0xfd, 0x77 }; | ||
1439 | struct rtl_epatch_header *epatch_info; | ||
1440 | unsigned char *buf; | ||
1441 | int i, ret, len; | ||
1442 | size_t min_size; | ||
1443 | u8 opcode, length, data, rom_version = 0; | ||
1444 | int project_id = -1; | ||
1445 | const unsigned char *fwptr, *chip_id_base; | ||
1446 | const unsigned char *patch_length_base, *patch_offset_base; | ||
1447 | u32 patch_offset = 0; | ||
1448 | u16 patch_length, num_patches; | ||
1449 | const u16 project_id_to_lmp_subver[] = { | ||
1450 | RTL_ROM_LMP_8723A, | ||
1451 | RTL_ROM_LMP_8723B, | ||
1452 | RTL_ROM_LMP_8821A, | ||
1453 | RTL_ROM_LMP_8761A | ||
1454 | }; | ||
1455 | |||
1456 | ret = rtl_read_rom_version(hdev, &rom_version); | ||
1457 | if (ret) | ||
1458 | return -bt_to_errno(ret); | ||
1459 | |||
1460 | min_size = sizeof(struct rtl_epatch_header) + sizeof(extension_sig) + 3; | ||
1461 | if (fw->size < min_size) | ||
1462 | return -EINVAL; | ||
1463 | |||
1464 | fwptr = fw->data + fw->size - sizeof(extension_sig); | ||
1465 | if (memcmp(fwptr, extension_sig, sizeof(extension_sig)) != 0) { | ||
1466 | BT_ERR("%s: extension section signature mismatch", hdev->name); | ||
1467 | return -EINVAL; | ||
1468 | } | ||
1469 | |||
1470 | /* Loop from the end of the firmware parsing instructions, until | ||
1471 | * we find an instruction that identifies the "project ID" for the | ||
1472 | * hardware supported by this firwmare file. | ||
1473 | * Once we have that, we double-check that that project_id is suitable | ||
1474 | * for the hardware we are working with. | ||
1475 | */ | ||
1476 | while (fwptr >= fw->data + (sizeof(struct rtl_epatch_header) + 3)) { | ||
1477 | opcode = *--fwptr; | ||
1478 | length = *--fwptr; | ||
1479 | data = *--fwptr; | ||
1480 | |||
1481 | BT_DBG("check op=%x len=%x data=%x", opcode, length, data); | ||
1482 | |||
1483 | if (opcode == 0xff) /* EOF */ | ||
1484 | break; | ||
1485 | |||
1486 | if (length == 0) { | ||
1487 | BT_ERR("%s: found instruction with length 0", | ||
1488 | hdev->name); | ||
1489 | return -EINVAL; | ||
1490 | } | ||
1491 | |||
1492 | if (opcode == 0 && length == 1) { | ||
1493 | project_id = data; | ||
1494 | break; | ||
1495 | } | ||
1496 | |||
1497 | fwptr -= length; | ||
1498 | } | ||
1499 | |||
1500 | if (project_id < 0) { | ||
1501 | BT_ERR("%s: failed to find version instruction", hdev->name); | ||
1502 | return -EINVAL; | ||
1503 | } | ||
1504 | |||
1505 | if (project_id >= ARRAY_SIZE(project_id_to_lmp_subver)) { | ||
1506 | BT_ERR("%s: unknown project id %d", hdev->name, project_id); | ||
1507 | return -EINVAL; | ||
1508 | } | ||
1509 | |||
1510 | if (lmp_subver != project_id_to_lmp_subver[project_id]) { | ||
1511 | BT_ERR("%s: firmware is for %x but this is a %x", hdev->name, | ||
1512 | project_id_to_lmp_subver[project_id], lmp_subver); | ||
1513 | return -EINVAL; | ||
1514 | } | ||
1515 | |||
1516 | epatch_info = (struct rtl_epatch_header *)fw->data; | ||
1517 | if (memcmp(epatch_info->signature, RTL_EPATCH_SIGNATURE, 8) != 0) { | ||
1518 | BT_ERR("%s: bad EPATCH signature", hdev->name); | ||
1519 | return -EINVAL; | ||
1520 | } | ||
1521 | |||
1522 | num_patches = le16_to_cpu(epatch_info->num_patches); | ||
1523 | BT_DBG("fw_version=%x, num_patches=%d", | ||
1524 | le32_to_cpu(epatch_info->fw_version), num_patches); | ||
1525 | |||
1526 | /* After the rtl_epatch_header there is a funky patch metadata section. | ||
1527 | * Assuming 2 patches, the layout is: | ||
1528 | * ChipID1 ChipID2 PatchLength1 PatchLength2 PatchOffset1 PatchOffset2 | ||
1529 | * | ||
1530 | * Find the right patch for this chip. | ||
1531 | */ | ||
1532 | min_size += 8 * num_patches; | ||
1533 | if (fw->size < min_size) | ||
1534 | return -EINVAL; | ||
1535 | |||
1536 | chip_id_base = fw->data + sizeof(struct rtl_epatch_header); | ||
1537 | patch_length_base = chip_id_base + (sizeof(u16) * num_patches); | ||
1538 | patch_offset_base = patch_length_base + (sizeof(u16) * num_patches); | ||
1539 | for (i = 0; i < num_patches; i++) { | ||
1540 | u16 chip_id = get_unaligned_le16(chip_id_base + | ||
1541 | (i * sizeof(u16))); | ||
1542 | if (chip_id == rom_version + 1) { | ||
1543 | patch_length = get_unaligned_le16(patch_length_base + | ||
1544 | (i * sizeof(u16))); | ||
1545 | patch_offset = get_unaligned_le32(patch_offset_base + | ||
1546 | (i * sizeof(u32))); | ||
1547 | break; | ||
1548 | } | ||
1549 | } | ||
1550 | |||
1551 | if (!patch_offset) { | ||
1552 | BT_ERR("%s: didn't find patch for chip id %d", | ||
1553 | hdev->name, rom_version); | ||
1554 | return -EINVAL; | ||
1555 | } | ||
1556 | |||
1557 | BT_DBG("length=%x offset=%x index %d", patch_length, patch_offset, i); | ||
1558 | min_size = patch_offset + patch_length; | ||
1559 | if (fw->size < min_size) | ||
1560 | return -EINVAL; | ||
1561 | |||
1562 | /* Copy the firmware into a new buffer and write the version at | ||
1563 | * the end. | ||
1564 | */ | ||
1565 | len = patch_length; | ||
1566 | buf = kmemdup(fw->data + patch_offset, patch_length, GFP_KERNEL); | ||
1567 | if (!buf) | ||
1568 | return -ENOMEM; | ||
1569 | |||
1570 | memcpy(buf + patch_length - 4, &epatch_info->fw_version, 4); | ||
1571 | |||
1572 | *_buf = buf; | ||
1573 | return len; | ||
1574 | } | ||
1575 | |||
1576 | static int rtl_download_firmware(struct hci_dev *hdev, | ||
1577 | const unsigned char *data, int fw_len) | ||
1578 | { | ||
1579 | struct rtl_download_cmd *dl_cmd; | ||
1580 | int frag_num = fw_len / RTL_FRAG_LEN + 1; | ||
1581 | int frag_len = RTL_FRAG_LEN; | ||
1582 | int ret = 0; | ||
1583 | int i; | ||
1584 | |||
1585 | dl_cmd = kmalloc(sizeof(struct rtl_download_cmd), GFP_KERNEL); | ||
1586 | if (!dl_cmd) | ||
1587 | return -ENOMEM; | ||
1588 | |||
1589 | for (i = 0; i < frag_num; i++) { | ||
1590 | struct rtl_download_response *dl_resp; | ||
1591 | struct sk_buff *skb; | ||
1592 | |||
1593 | BT_DBG("download fw (%d/%d)", i, frag_num); | ||
1594 | |||
1595 | dl_cmd->index = i; | ||
1596 | if (i == (frag_num - 1)) { | ||
1597 | dl_cmd->index |= 0x80; /* data end */ | ||
1598 | frag_len = fw_len % RTL_FRAG_LEN; | ||
1599 | } | ||
1600 | memcpy(dl_cmd->data, data, frag_len); | ||
1601 | |||
1602 | /* Send download command */ | ||
1603 | skb = __hci_cmd_sync(hdev, 0xfc20, frag_len + 1, dl_cmd, | ||
1604 | HCI_INIT_TIMEOUT); | ||
1605 | if (IS_ERR(skb)) { | ||
1606 | BT_ERR("%s: download fw command failed (%ld)", | ||
1607 | hdev->name, PTR_ERR(skb)); | ||
1608 | ret = -PTR_ERR(skb); | ||
1609 | goto out; | ||
1610 | } | ||
1611 | |||
1612 | if (skb->len != sizeof(*dl_resp)) { | ||
1613 | BT_ERR("%s: download fw event length mismatch", | ||
1614 | hdev->name); | ||
1615 | kfree_skb(skb); | ||
1616 | ret = -EIO; | ||
1617 | goto out; | ||
1618 | } | ||
1619 | |||
1620 | dl_resp = (struct rtl_download_response *)skb->data; | ||
1621 | if (dl_resp->status != 0) { | ||
1622 | kfree_skb(skb); | ||
1623 | ret = bt_to_errno(dl_resp->status); | ||
1624 | goto out; | ||
1625 | } | ||
1626 | |||
1627 | kfree_skb(skb); | ||
1628 | data += RTL_FRAG_LEN; | ||
1629 | } | ||
1630 | |||
1631 | out: | ||
1632 | kfree(dl_cmd); | ||
1633 | return ret; | ||
1634 | } | ||
1635 | |||
1636 | static int btusb_setup_rtl8723a(struct hci_dev *hdev) | ||
1637 | { | ||
1638 | struct btusb_data *data = dev_get_drvdata(&hdev->dev); | ||
1639 | struct usb_device *udev = interface_to_usbdev(data->intf); | ||
1640 | const struct firmware *fw; | ||
1641 | int ret; | ||
1642 | |||
1643 | BT_INFO("%s: rtl: loading rtl_bt/rtl8723a_fw.bin", hdev->name); | ||
1644 | ret = request_firmware(&fw, "rtl_bt/rtl8723a_fw.bin", &udev->dev); | ||
1645 | if (ret < 0) { | ||
1646 | BT_ERR("%s: Failed to load rtl_bt/rtl8723a_fw.bin", hdev->name); | ||
1647 | return ret; | ||
1648 | } | ||
1649 | |||
1650 | if (fw->size < 8) { | ||
1651 | ret = -EINVAL; | ||
1652 | goto out; | ||
1653 | } | ||
1654 | |||
1655 | /* Check that the firmware doesn't have the epatch signature | ||
1656 | * (which is only for RTL8723B and newer). | ||
1657 | */ | ||
1658 | if (!memcmp(fw->data, RTL_EPATCH_SIGNATURE, 8)) { | ||
1659 | BT_ERR("%s: unexpected EPATCH signature!", hdev->name); | ||
1660 | ret = -EINVAL; | ||
1661 | goto out; | ||
1662 | } | ||
1663 | |||
1664 | ret = rtl_download_firmware(hdev, fw->data, fw->size); | ||
1665 | |||
1666 | out: | ||
1667 | release_firmware(fw); | ||
1668 | return ret; | ||
1669 | } | ||
1670 | |||
1671 | static int btusb_setup_rtl8723b(struct hci_dev *hdev, u16 lmp_subver, | ||
1672 | const char *fw_name) | ||
1673 | { | ||
1674 | struct btusb_data *data = dev_get_drvdata(&hdev->dev); | ||
1675 | struct usb_device *udev = interface_to_usbdev(data->intf); | ||
1676 | unsigned char *fw_data = NULL; | ||
1677 | const struct firmware *fw; | ||
1678 | int ret; | ||
1679 | |||
1680 | BT_INFO("%s: rtl: loading %s", hdev->name, fw_name); | ||
1681 | ret = request_firmware(&fw, fw_name, &udev->dev); | ||
1682 | if (ret < 0) { | ||
1683 | BT_ERR("%s: Failed to load %s", hdev->name, fw_name); | ||
1684 | return ret; | ||
1685 | } | ||
1686 | |||
1687 | ret = rtl8723b_parse_firmware(hdev, lmp_subver, fw, &fw_data); | ||
1688 | if (ret < 0) | ||
1689 | goto out; | ||
1690 | |||
1691 | ret = rtl_download_firmware(hdev, fw_data, ret); | ||
1692 | kfree(fw_data); | ||
1693 | if (ret < 0) | ||
1694 | goto out; | ||
1695 | |||
1696 | out: | ||
1697 | release_firmware(fw); | ||
1698 | return ret; | ||
1699 | } | ||
1700 | |||
1701 | static int btusb_setup_realtek(struct hci_dev *hdev) | ||
1702 | { | ||
1703 | struct sk_buff *skb; | ||
1704 | struct hci_rp_read_local_version *resp; | ||
1705 | u16 lmp_subver; | ||
1706 | |||
1707 | skb = btusb_read_local_version(hdev); | ||
1708 | if (IS_ERR(skb)) | ||
1709 | return -PTR_ERR(skb); | ||
1710 | |||
1711 | resp = (struct hci_rp_read_local_version *)skb->data; | ||
1712 | BT_INFO("%s: rtl: examining hci_ver=%02x hci_rev=%04x lmp_ver=%02x " | ||
1713 | "lmp_subver=%04x", hdev->name, resp->hci_ver, resp->hci_rev, | ||
1714 | resp->lmp_ver, resp->lmp_subver); | ||
1715 | |||
1716 | lmp_subver = le16_to_cpu(resp->lmp_subver); | ||
1717 | kfree_skb(skb); | ||
1718 | |||
1719 | /* Match a set of subver values that correspond to stock firmware, | ||
1720 | * which is not compatible with standard btusb. | ||
1721 | * If matched, upload an alternative firmware that does conform to | ||
1722 | * standard btusb. Once that firmware is uploaded, the subver changes | ||
1723 | * to a different value. | ||
1724 | */ | ||
1725 | switch (lmp_subver) { | ||
1726 | case RTL_ROM_LMP_8723A: | ||
1727 | case RTL_ROM_LMP_3499: | ||
1728 | return btusb_setup_rtl8723a(hdev); | ||
1729 | case RTL_ROM_LMP_8723B: | ||
1730 | return btusb_setup_rtl8723b(hdev, lmp_subver, | ||
1731 | "rtl_bt/rtl8723b_fw.bin"); | ||
1732 | case RTL_ROM_LMP_8821A: | ||
1733 | return btusb_setup_rtl8723b(hdev, lmp_subver, | ||
1734 | "rtl_bt/rtl8821a_fw.bin"); | ||
1735 | case RTL_ROM_LMP_8761A: | ||
1736 | return btusb_setup_rtl8723b(hdev, lmp_subver, | ||
1737 | "rtl_bt/rtl8761a_fw.bin"); | ||
1738 | default: | ||
1739 | BT_INFO("rtl: assuming no firmware upload needed."); | ||
1740 | return 0; | ||
1741 | } | ||
1742 | } | ||
1743 | |||
1348 | static const struct firmware *btusb_setup_intel_get_fw(struct hci_dev *hdev, | 1744 | static const struct firmware *btusb_setup_intel_get_fw(struct hci_dev *hdev, |
1349 | struct intel_version *ver) | 1745 | struct intel_version *ver) |
1350 | { | 1746 | { |
@@ -2577,7 +2973,7 @@ static int btusb_setup_qca(struct hci_dev *hdev) | |||
2577 | int i, err; | 2973 | int i, err; |
2578 | 2974 | ||
2579 | err = btusb_qca_send_vendor_req(hdev, QCA_GET_TARGET_VERSION, &ver, | 2975 | err = btusb_qca_send_vendor_req(hdev, QCA_GET_TARGET_VERSION, &ver, |
2580 | sizeof(ver)); | 2976 | sizeof(ver)); |
2581 | if (err < 0) | 2977 | if (err < 0) |
2582 | return err; | 2978 | return err; |
2583 | 2979 | ||
@@ -2776,6 +3172,9 @@ static int btusb_probe(struct usb_interface *intf, | |||
2776 | hdev->set_bdaddr = btusb_set_bdaddr_ath3012; | 3172 | hdev->set_bdaddr = btusb_set_bdaddr_ath3012; |
2777 | } | 3173 | } |
2778 | 3174 | ||
3175 | if (id->driver_info & BTUSB_REALTEK) | ||
3176 | hdev->setup = btusb_setup_realtek; | ||
3177 | |||
2779 | if (id->driver_info & BTUSB_AMP) { | 3178 | if (id->driver_info & BTUSB_AMP) { |
2780 | /* AMP controllers do not support SCO packets */ | 3179 | /* AMP controllers do not support SCO packets */ |
2781 | data->isoc = NULL; | 3180 | data->isoc = NULL; |
diff --git a/drivers/bluetooth/hci_ath.c b/drivers/bluetooth/hci_ath.c index 1b3f8647ea2f..ec8fa0e0f036 100644 --- a/drivers/bluetooth/hci_ath.c +++ b/drivers/bluetooth/hci_ath.c | |||
@@ -95,7 +95,6 @@ static void ath_hci_uart_work(struct work_struct *work) | |||
95 | hci_uart_tx_wakeup(hu); | 95 | hci_uart_tx_wakeup(hu); |
96 | } | 96 | } |
97 | 97 | ||
98 | /* Initialize protocol */ | ||
99 | static int ath_open(struct hci_uart *hu) | 98 | static int ath_open(struct hci_uart *hu) |
100 | { | 99 | { |
101 | struct ath_struct *ath; | 100 | struct ath_struct *ath; |
@@ -116,8 +115,7 @@ static int ath_open(struct hci_uart *hu) | |||
116 | return 0; | 115 | return 0; |
117 | } | 116 | } |
118 | 117 | ||
119 | /* Flush protocol data */ | 118 | static int ath_close(struct hci_uart *hu) |
120 | static int ath_flush(struct hci_uart *hu) | ||
121 | { | 119 | { |
122 | struct ath_struct *ath = hu->priv; | 120 | struct ath_struct *ath = hu->priv; |
123 | 121 | ||
@@ -125,11 +123,17 @@ static int ath_flush(struct hci_uart *hu) | |||
125 | 123 | ||
126 | skb_queue_purge(&ath->txq); | 124 | skb_queue_purge(&ath->txq); |
127 | 125 | ||
126 | kfree_skb(ath->rx_skb); | ||
127 | |||
128 | cancel_work_sync(&ath->ctxtsw); | ||
129 | |||
130 | hu->priv = NULL; | ||
131 | kfree(ath); | ||
132 | |||
128 | return 0; | 133 | return 0; |
129 | } | 134 | } |
130 | 135 | ||
131 | /* Close protocol */ | 136 | static int ath_flush(struct hci_uart *hu) |
132 | static int ath_close(struct hci_uart *hu) | ||
133 | { | 137 | { |
134 | struct ath_struct *ath = hu->priv; | 138 | struct ath_struct *ath = hu->priv; |
135 | 139 | ||
@@ -137,19 +141,65 @@ static int ath_close(struct hci_uart *hu) | |||
137 | 141 | ||
138 | skb_queue_purge(&ath->txq); | 142 | skb_queue_purge(&ath->txq); |
139 | 143 | ||
140 | kfree_skb(ath->rx_skb); | 144 | return 0; |
145 | } | ||
141 | 146 | ||
142 | cancel_work_sync(&ath->ctxtsw); | 147 | static int ath_set_bdaddr(struct hci_dev *hdev, const bdaddr_t *bdaddr) |
148 | { | ||
149 | struct sk_buff *skb; | ||
150 | u8 buf[10]; | ||
151 | int err; | ||
152 | |||
153 | buf[0] = 0x01; | ||
154 | buf[1] = 0x01; | ||
155 | buf[2] = 0x00; | ||
156 | buf[3] = sizeof(bdaddr_t); | ||
157 | memcpy(buf + 4, bdaddr, sizeof(bdaddr_t)); | ||
158 | |||
159 | skb = __hci_cmd_sync(hdev, 0xfc0b, sizeof(buf), buf, HCI_INIT_TIMEOUT); | ||
160 | if (IS_ERR(skb)) { | ||
161 | err = PTR_ERR(skb); | ||
162 | BT_ERR("%s: Change address command failed (%d)", | ||
163 | hdev->name, err); | ||
164 | return err; | ||
165 | } | ||
166 | kfree_skb(skb); | ||
143 | 167 | ||
144 | hu->priv = NULL; | 168 | return 0; |
145 | kfree(ath); | 169 | } |
170 | |||
171 | static int ath_setup(struct hci_uart *hu) | ||
172 | { | ||
173 | BT_DBG("hu %p", hu); | ||
174 | |||
175 | hu->hdev->set_bdaddr = ath_set_bdaddr; | ||
146 | 176 | ||
147 | return 0; | 177 | return 0; |
148 | } | 178 | } |
149 | 179 | ||
180 | static const struct h4_recv_pkt ath_recv_pkts[] = { | ||
181 | { H4_RECV_ACL, .recv = hci_recv_frame }, | ||
182 | { H4_RECV_SCO, .recv = hci_recv_frame }, | ||
183 | { H4_RECV_EVENT, .recv = hci_recv_frame }, | ||
184 | }; | ||
185 | |||
186 | static int ath_recv(struct hci_uart *hu, const void *data, int count) | ||
187 | { | ||
188 | struct ath_struct *ath = hu->priv; | ||
189 | |||
190 | ath->rx_skb = h4_recv_buf(hu->hdev, ath->rx_skb, data, count, | ||
191 | ath_recv_pkts, ARRAY_SIZE(ath_recv_pkts)); | ||
192 | if (IS_ERR(ath->rx_skb)) { | ||
193 | int err = PTR_ERR(ath->rx_skb); | ||
194 | BT_ERR("%s: Frame reassembly failed (%d)", hu->hdev->name, err); | ||
195 | return err; | ||
196 | } | ||
197 | |||
198 | return count; | ||
199 | } | ||
200 | |||
150 | #define HCI_OP_ATH_SLEEP 0xFC04 | 201 | #define HCI_OP_ATH_SLEEP 0xFC04 |
151 | 202 | ||
152 | /* Enqueue frame for transmittion */ | ||
153 | static int ath_enqueue(struct hci_uart *hu, struct sk_buff *skb) | 203 | static int ath_enqueue(struct hci_uart *hu, struct sk_buff *skb) |
154 | { | 204 | { |
155 | struct ath_struct *ath = hu->priv; | 205 | struct ath_struct *ath = hu->priv; |
@@ -159,8 +209,7 @@ static int ath_enqueue(struct hci_uart *hu, struct sk_buff *skb) | |||
159 | return 0; | 209 | return 0; |
160 | } | 210 | } |
161 | 211 | ||
162 | /* | 212 | /* Update power management enable flag with parameters of |
163 | * Update power management enable flag with parameters of | ||
164 | * HCI sleep enable vendor specific HCI command. | 213 | * HCI sleep enable vendor specific HCI command. |
165 | */ | 214 | */ |
166 | if (bt_cb(skb)->pkt_type == HCI_COMMAND_PKT) { | 215 | if (bt_cb(skb)->pkt_type == HCI_COMMAND_PKT) { |
@@ -190,37 +239,16 @@ static struct sk_buff *ath_dequeue(struct hci_uart *hu) | |||
190 | return skb_dequeue(&ath->txq); | 239 | return skb_dequeue(&ath->txq); |
191 | } | 240 | } |
192 | 241 | ||
193 | static const struct h4_recv_pkt ath_recv_pkts[] = { | ||
194 | { H4_RECV_ACL, .recv = hci_recv_frame }, | ||
195 | { H4_RECV_SCO, .recv = hci_recv_frame }, | ||
196 | { H4_RECV_EVENT, .recv = hci_recv_frame }, | ||
197 | }; | ||
198 | |||
199 | /* Recv data */ | ||
200 | static int ath_recv(struct hci_uart *hu, const void *data, int count) | ||
201 | { | ||
202 | struct ath_struct *ath = hu->priv; | ||
203 | |||
204 | ath->rx_skb = h4_recv_buf(hu->hdev, ath->rx_skb, data, count, | ||
205 | ath_recv_pkts, ARRAY_SIZE(ath_recv_pkts)); | ||
206 | if (IS_ERR(ath->rx_skb)) { | ||
207 | int err = PTR_ERR(ath->rx_skb); | ||
208 | BT_ERR("%s: Frame reassembly failed (%d)", hu->hdev->name, err); | ||
209 | return err; | ||
210 | } | ||
211 | |||
212 | return count; | ||
213 | } | ||
214 | |||
215 | static const struct hci_uart_proto athp = { | 242 | static const struct hci_uart_proto athp = { |
216 | .id = HCI_UART_ATH3K, | 243 | .id = HCI_UART_ATH3K, |
217 | .name = "ATH3K", | 244 | .name = "ATH3K", |
218 | .open = ath_open, | 245 | .open = ath_open, |
219 | .close = ath_close, | 246 | .close = ath_close, |
247 | .flush = ath_flush, | ||
248 | .setup = ath_setup, | ||
220 | .recv = ath_recv, | 249 | .recv = ath_recv, |
221 | .enqueue = ath_enqueue, | 250 | .enqueue = ath_enqueue, |
222 | .dequeue = ath_dequeue, | 251 | .dequeue = ath_dequeue, |
223 | .flush = ath_flush, | ||
224 | }; | 252 | }; |
225 | 253 | ||
226 | int __init ath_init(void) | 254 | int __init ath_init(void) |
diff --git a/drivers/net/ieee802154/at86rf230.c b/drivers/net/ieee802154/at86rf230.c index 38026650c038..67d00fbc2e0e 100644 --- a/drivers/net/ieee802154/at86rf230.c +++ b/drivers/net/ieee802154/at86rf230.c | |||
@@ -85,6 +85,7 @@ struct at86rf230_local { | |||
85 | struct ieee802154_hw *hw; | 85 | struct ieee802154_hw *hw; |
86 | struct at86rf2xx_chip_data *data; | 86 | struct at86rf2xx_chip_data *data; |
87 | struct regmap *regmap; | 87 | struct regmap *regmap; |
88 | int slp_tr; | ||
88 | 89 | ||
89 | struct completion state_complete; | 90 | struct completion state_complete; |
90 | struct at86rf230_state_change state; | 91 | struct at86rf230_state_change state; |
@@ -95,163 +96,164 @@ struct at86rf230_local { | |||
95 | unsigned long cal_timeout; | 96 | unsigned long cal_timeout; |
96 | s8 max_frame_retries; | 97 | s8 max_frame_retries; |
97 | bool is_tx; | 98 | bool is_tx; |
99 | bool is_tx_from_off; | ||
98 | u8 tx_retry; | 100 | u8 tx_retry; |
99 | struct sk_buff *tx_skb; | 101 | struct sk_buff *tx_skb; |
100 | struct at86rf230_state_change tx; | 102 | struct at86rf230_state_change tx; |
101 | }; | 103 | }; |
102 | 104 | ||
103 | #define RG_TRX_STATUS (0x01) | 105 | #define RG_TRX_STATUS (0x01) |
104 | #define SR_TRX_STATUS 0x01, 0x1f, 0 | 106 | #define SR_TRX_STATUS 0x01, 0x1f, 0 |
105 | #define SR_RESERVED_01_3 0x01, 0x20, 5 | 107 | #define SR_RESERVED_01_3 0x01, 0x20, 5 |
106 | #define SR_CCA_STATUS 0x01, 0x40, 6 | 108 | #define SR_CCA_STATUS 0x01, 0x40, 6 |
107 | #define SR_CCA_DONE 0x01, 0x80, 7 | 109 | #define SR_CCA_DONE 0x01, 0x80, 7 |
108 | #define RG_TRX_STATE (0x02) | 110 | #define RG_TRX_STATE (0x02) |
109 | #define SR_TRX_CMD 0x02, 0x1f, 0 | 111 | #define SR_TRX_CMD 0x02, 0x1f, 0 |
110 | #define SR_TRAC_STATUS 0x02, 0xe0, 5 | 112 | #define SR_TRAC_STATUS 0x02, 0xe0, 5 |
111 | #define RG_TRX_CTRL_0 (0x03) | 113 | #define RG_TRX_CTRL_0 (0x03) |
112 | #define SR_CLKM_CTRL 0x03, 0x07, 0 | 114 | #define SR_CLKM_CTRL 0x03, 0x07, 0 |
113 | #define SR_CLKM_SHA_SEL 0x03, 0x08, 3 | 115 | #define SR_CLKM_SHA_SEL 0x03, 0x08, 3 |
114 | #define SR_PAD_IO_CLKM 0x03, 0x30, 4 | 116 | #define SR_PAD_IO_CLKM 0x03, 0x30, 4 |
115 | #define SR_PAD_IO 0x03, 0xc0, 6 | 117 | #define SR_PAD_IO 0x03, 0xc0, 6 |
116 | #define RG_TRX_CTRL_1 (0x04) | 118 | #define RG_TRX_CTRL_1 (0x04) |
117 | #define SR_IRQ_POLARITY 0x04, 0x01, 0 | 119 | #define SR_IRQ_POLARITY 0x04, 0x01, 0 |
118 | #define SR_IRQ_MASK_MODE 0x04, 0x02, 1 | 120 | #define SR_IRQ_MASK_MODE 0x04, 0x02, 1 |
119 | #define SR_SPI_CMD_MODE 0x04, 0x0c, 2 | 121 | #define SR_SPI_CMD_MODE 0x04, 0x0c, 2 |
120 | #define SR_RX_BL_CTRL 0x04, 0x10, 4 | 122 | #define SR_RX_BL_CTRL 0x04, 0x10, 4 |
121 | #define SR_TX_AUTO_CRC_ON 0x04, 0x20, 5 | 123 | #define SR_TX_AUTO_CRC_ON 0x04, 0x20, 5 |
122 | #define SR_IRQ_2_EXT_EN 0x04, 0x40, 6 | 124 | #define SR_IRQ_2_EXT_EN 0x04, 0x40, 6 |
123 | #define SR_PA_EXT_EN 0x04, 0x80, 7 | 125 | #define SR_PA_EXT_EN 0x04, 0x80, 7 |
124 | #define RG_PHY_TX_PWR (0x05) | 126 | #define RG_PHY_TX_PWR (0x05) |
125 | #define SR_TX_PWR 0x05, 0x0f, 0 | 127 | #define SR_TX_PWR 0x05, 0x0f, 0 |
126 | #define SR_PA_LT 0x05, 0x30, 4 | 128 | #define SR_PA_LT 0x05, 0x30, 4 |
127 | #define SR_PA_BUF_LT 0x05, 0xc0, 6 | 129 | #define SR_PA_BUF_LT 0x05, 0xc0, 6 |
128 | #define RG_PHY_RSSI (0x06) | 130 | #define RG_PHY_RSSI (0x06) |
129 | #define SR_RSSI 0x06, 0x1f, 0 | 131 | #define SR_RSSI 0x06, 0x1f, 0 |
130 | #define SR_RND_VALUE 0x06, 0x60, 5 | 132 | #define SR_RND_VALUE 0x06, 0x60, 5 |
131 | #define SR_RX_CRC_VALID 0x06, 0x80, 7 | 133 | #define SR_RX_CRC_VALID 0x06, 0x80, 7 |
132 | #define RG_PHY_ED_LEVEL (0x07) | 134 | #define RG_PHY_ED_LEVEL (0x07) |
133 | #define SR_ED_LEVEL 0x07, 0xff, 0 | 135 | #define SR_ED_LEVEL 0x07, 0xff, 0 |
134 | #define RG_PHY_CC_CCA (0x08) | 136 | #define RG_PHY_CC_CCA (0x08) |
135 | #define SR_CHANNEL 0x08, 0x1f, 0 | 137 | #define SR_CHANNEL 0x08, 0x1f, 0 |
136 | #define SR_CCA_MODE 0x08, 0x60, 5 | 138 | #define SR_CCA_MODE 0x08, 0x60, 5 |
137 | #define SR_CCA_REQUEST 0x08, 0x80, 7 | 139 | #define SR_CCA_REQUEST 0x08, 0x80, 7 |
138 | #define RG_CCA_THRES (0x09) | 140 | #define RG_CCA_THRES (0x09) |
139 | #define SR_CCA_ED_THRES 0x09, 0x0f, 0 | 141 | #define SR_CCA_ED_THRES 0x09, 0x0f, 0 |
140 | #define SR_RESERVED_09_1 0x09, 0xf0, 4 | 142 | #define SR_RESERVED_09_1 0x09, 0xf0, 4 |
141 | #define RG_RX_CTRL (0x0a) | 143 | #define RG_RX_CTRL (0x0a) |
142 | #define SR_PDT_THRES 0x0a, 0x0f, 0 | 144 | #define SR_PDT_THRES 0x0a, 0x0f, 0 |
143 | #define SR_RESERVED_0a_1 0x0a, 0xf0, 4 | 145 | #define SR_RESERVED_0a_1 0x0a, 0xf0, 4 |
144 | #define RG_SFD_VALUE (0x0b) | 146 | #define RG_SFD_VALUE (0x0b) |
145 | #define SR_SFD_VALUE 0x0b, 0xff, 0 | 147 | #define SR_SFD_VALUE 0x0b, 0xff, 0 |
146 | #define RG_TRX_CTRL_2 (0x0c) | 148 | #define RG_TRX_CTRL_2 (0x0c) |
147 | #define SR_OQPSK_DATA_RATE 0x0c, 0x03, 0 | 149 | #define SR_OQPSK_DATA_RATE 0x0c, 0x03, 0 |
148 | #define SR_SUB_MODE 0x0c, 0x04, 2 | 150 | #define SR_SUB_MODE 0x0c, 0x04, 2 |
149 | #define SR_BPSK_QPSK 0x0c, 0x08, 3 | 151 | #define SR_BPSK_QPSK 0x0c, 0x08, 3 |
150 | #define SR_OQPSK_SUB1_RC_EN 0x0c, 0x10, 4 | 152 | #define SR_OQPSK_SUB1_RC_EN 0x0c, 0x10, 4 |
151 | #define SR_RESERVED_0c_5 0x0c, 0x60, 5 | 153 | #define SR_RESERVED_0c_5 0x0c, 0x60, 5 |
152 | #define SR_RX_SAFE_MODE 0x0c, 0x80, 7 | 154 | #define SR_RX_SAFE_MODE 0x0c, 0x80, 7 |
153 | #define RG_ANT_DIV (0x0d) | 155 | #define RG_ANT_DIV (0x0d) |
154 | #define SR_ANT_CTRL 0x0d, 0x03, 0 | 156 | #define SR_ANT_CTRL 0x0d, 0x03, 0 |
155 | #define SR_ANT_EXT_SW_EN 0x0d, 0x04, 2 | 157 | #define SR_ANT_EXT_SW_EN 0x0d, 0x04, 2 |
156 | #define SR_ANT_DIV_EN 0x0d, 0x08, 3 | 158 | #define SR_ANT_DIV_EN 0x0d, 0x08, 3 |
157 | #define SR_RESERVED_0d_2 0x0d, 0x70, 4 | 159 | #define SR_RESERVED_0d_2 0x0d, 0x70, 4 |
158 | #define SR_ANT_SEL 0x0d, 0x80, 7 | 160 | #define SR_ANT_SEL 0x0d, 0x80, 7 |
159 | #define RG_IRQ_MASK (0x0e) | 161 | #define RG_IRQ_MASK (0x0e) |
160 | #define SR_IRQ_MASK 0x0e, 0xff, 0 | 162 | #define SR_IRQ_MASK 0x0e, 0xff, 0 |
161 | #define RG_IRQ_STATUS (0x0f) | 163 | #define RG_IRQ_STATUS (0x0f) |
162 | #define SR_IRQ_0_PLL_LOCK 0x0f, 0x01, 0 | 164 | #define SR_IRQ_0_PLL_LOCK 0x0f, 0x01, 0 |
163 | #define SR_IRQ_1_PLL_UNLOCK 0x0f, 0x02, 1 | 165 | #define SR_IRQ_1_PLL_UNLOCK 0x0f, 0x02, 1 |
164 | #define SR_IRQ_2_RX_START 0x0f, 0x04, 2 | 166 | #define SR_IRQ_2_RX_START 0x0f, 0x04, 2 |
165 | #define SR_IRQ_3_TRX_END 0x0f, 0x08, 3 | 167 | #define SR_IRQ_3_TRX_END 0x0f, 0x08, 3 |
166 | #define SR_IRQ_4_CCA_ED_DONE 0x0f, 0x10, 4 | 168 | #define SR_IRQ_4_CCA_ED_DONE 0x0f, 0x10, 4 |
167 | #define SR_IRQ_5_AMI 0x0f, 0x20, 5 | 169 | #define SR_IRQ_5_AMI 0x0f, 0x20, 5 |
168 | #define SR_IRQ_6_TRX_UR 0x0f, 0x40, 6 | 170 | #define SR_IRQ_6_TRX_UR 0x0f, 0x40, 6 |
169 | #define SR_IRQ_7_BAT_LOW 0x0f, 0x80, 7 | 171 | #define SR_IRQ_7_BAT_LOW 0x0f, 0x80, 7 |
170 | #define RG_VREG_CTRL (0x10) | 172 | #define RG_VREG_CTRL (0x10) |
171 | #define SR_RESERVED_10_6 0x10, 0x03, 0 | 173 | #define SR_RESERVED_10_6 0x10, 0x03, 0 |
172 | #define SR_DVDD_OK 0x10, 0x04, 2 | 174 | #define SR_DVDD_OK 0x10, 0x04, 2 |
173 | #define SR_DVREG_EXT 0x10, 0x08, 3 | 175 | #define SR_DVREG_EXT 0x10, 0x08, 3 |
174 | #define SR_RESERVED_10_3 0x10, 0x30, 4 | 176 | #define SR_RESERVED_10_3 0x10, 0x30, 4 |
175 | #define SR_AVDD_OK 0x10, 0x40, 6 | 177 | #define SR_AVDD_OK 0x10, 0x40, 6 |
176 | #define SR_AVREG_EXT 0x10, 0x80, 7 | 178 | #define SR_AVREG_EXT 0x10, 0x80, 7 |
177 | #define RG_BATMON (0x11) | 179 | #define RG_BATMON (0x11) |
178 | #define SR_BATMON_VTH 0x11, 0x0f, 0 | 180 | #define SR_BATMON_VTH 0x11, 0x0f, 0 |
179 | #define SR_BATMON_HR 0x11, 0x10, 4 | 181 | #define SR_BATMON_HR 0x11, 0x10, 4 |
180 | #define SR_BATMON_OK 0x11, 0x20, 5 | 182 | #define SR_BATMON_OK 0x11, 0x20, 5 |
181 | #define SR_RESERVED_11_1 0x11, 0xc0, 6 | 183 | #define SR_RESERVED_11_1 0x11, 0xc0, 6 |
182 | #define RG_XOSC_CTRL (0x12) | 184 | #define RG_XOSC_CTRL (0x12) |
183 | #define SR_XTAL_TRIM 0x12, 0x0f, 0 | 185 | #define SR_XTAL_TRIM 0x12, 0x0f, 0 |
184 | #define SR_XTAL_MODE 0x12, 0xf0, 4 | 186 | #define SR_XTAL_MODE 0x12, 0xf0, 4 |
185 | #define RG_RX_SYN (0x15) | 187 | #define RG_RX_SYN (0x15) |
186 | #define SR_RX_PDT_LEVEL 0x15, 0x0f, 0 | 188 | #define SR_RX_PDT_LEVEL 0x15, 0x0f, 0 |
187 | #define SR_RESERVED_15_2 0x15, 0x70, 4 | 189 | #define SR_RESERVED_15_2 0x15, 0x70, 4 |
188 | #define SR_RX_PDT_DIS 0x15, 0x80, 7 | 190 | #define SR_RX_PDT_DIS 0x15, 0x80, 7 |
189 | #define RG_XAH_CTRL_1 (0x17) | 191 | #define RG_XAH_CTRL_1 (0x17) |
190 | #define SR_RESERVED_17_8 0x17, 0x01, 0 | 192 | #define SR_RESERVED_17_8 0x17, 0x01, 0 |
191 | #define SR_AACK_PROM_MODE 0x17, 0x02, 1 | 193 | #define SR_AACK_PROM_MODE 0x17, 0x02, 1 |
192 | #define SR_AACK_ACK_TIME 0x17, 0x04, 2 | 194 | #define SR_AACK_ACK_TIME 0x17, 0x04, 2 |
193 | #define SR_RESERVED_17_5 0x17, 0x08, 3 | 195 | #define SR_RESERVED_17_5 0x17, 0x08, 3 |
194 | #define SR_AACK_UPLD_RES_FT 0x17, 0x10, 4 | 196 | #define SR_AACK_UPLD_RES_FT 0x17, 0x10, 4 |
195 | #define SR_AACK_FLTR_RES_FT 0x17, 0x20, 5 | 197 | #define SR_AACK_FLTR_RES_FT 0x17, 0x20, 5 |
196 | #define SR_CSMA_LBT_MODE 0x17, 0x40, 6 | 198 | #define SR_CSMA_LBT_MODE 0x17, 0x40, 6 |
197 | #define SR_RESERVED_17_1 0x17, 0x80, 7 | 199 | #define SR_RESERVED_17_1 0x17, 0x80, 7 |
198 | #define RG_FTN_CTRL (0x18) | 200 | #define RG_FTN_CTRL (0x18) |
199 | #define SR_RESERVED_18_2 0x18, 0x7f, 0 | 201 | #define SR_RESERVED_18_2 0x18, 0x7f, 0 |
200 | #define SR_FTN_START 0x18, 0x80, 7 | 202 | #define SR_FTN_START 0x18, 0x80, 7 |
201 | #define RG_PLL_CF (0x1a) | 203 | #define RG_PLL_CF (0x1a) |
202 | #define SR_RESERVED_1a_2 0x1a, 0x7f, 0 | 204 | #define SR_RESERVED_1a_2 0x1a, 0x7f, 0 |
203 | #define SR_PLL_CF_START 0x1a, 0x80, 7 | 205 | #define SR_PLL_CF_START 0x1a, 0x80, 7 |
204 | #define RG_PLL_DCU (0x1b) | 206 | #define RG_PLL_DCU (0x1b) |
205 | #define SR_RESERVED_1b_3 0x1b, 0x3f, 0 | 207 | #define SR_RESERVED_1b_3 0x1b, 0x3f, 0 |
206 | #define SR_RESERVED_1b_2 0x1b, 0x40, 6 | 208 | #define SR_RESERVED_1b_2 0x1b, 0x40, 6 |
207 | #define SR_PLL_DCU_START 0x1b, 0x80, 7 | 209 | #define SR_PLL_DCU_START 0x1b, 0x80, 7 |
208 | #define RG_PART_NUM (0x1c) | 210 | #define RG_PART_NUM (0x1c) |
209 | #define SR_PART_NUM 0x1c, 0xff, 0 | 211 | #define SR_PART_NUM 0x1c, 0xff, 0 |
210 | #define RG_VERSION_NUM (0x1d) | 212 | #define RG_VERSION_NUM (0x1d) |
211 | #define SR_VERSION_NUM 0x1d, 0xff, 0 | 213 | #define SR_VERSION_NUM 0x1d, 0xff, 0 |
212 | #define RG_MAN_ID_0 (0x1e) | 214 | #define RG_MAN_ID_0 (0x1e) |
213 | #define SR_MAN_ID_0 0x1e, 0xff, 0 | 215 | #define SR_MAN_ID_0 0x1e, 0xff, 0 |
214 | #define RG_MAN_ID_1 (0x1f) | 216 | #define RG_MAN_ID_1 (0x1f) |
215 | #define SR_MAN_ID_1 0x1f, 0xff, 0 | 217 | #define SR_MAN_ID_1 0x1f, 0xff, 0 |
216 | #define RG_SHORT_ADDR_0 (0x20) | 218 | #define RG_SHORT_ADDR_0 (0x20) |
217 | #define SR_SHORT_ADDR_0 0x20, 0xff, 0 | 219 | #define SR_SHORT_ADDR_0 0x20, 0xff, 0 |
218 | #define RG_SHORT_ADDR_1 (0x21) | 220 | #define RG_SHORT_ADDR_1 (0x21) |
219 | #define SR_SHORT_ADDR_1 0x21, 0xff, 0 | 221 | #define SR_SHORT_ADDR_1 0x21, 0xff, 0 |
220 | #define RG_PAN_ID_0 (0x22) | 222 | #define RG_PAN_ID_0 (0x22) |
221 | #define SR_PAN_ID_0 0x22, 0xff, 0 | 223 | #define SR_PAN_ID_0 0x22, 0xff, 0 |
222 | #define RG_PAN_ID_1 (0x23) | 224 | #define RG_PAN_ID_1 (0x23) |
223 | #define SR_PAN_ID_1 0x23, 0xff, 0 | 225 | #define SR_PAN_ID_1 0x23, 0xff, 0 |
224 | #define RG_IEEE_ADDR_0 (0x24) | 226 | #define RG_IEEE_ADDR_0 (0x24) |
225 | #define SR_IEEE_ADDR_0 0x24, 0xff, 0 | 227 | #define SR_IEEE_ADDR_0 0x24, 0xff, 0 |
226 | #define RG_IEEE_ADDR_1 (0x25) | 228 | #define RG_IEEE_ADDR_1 (0x25) |
227 | #define SR_IEEE_ADDR_1 0x25, 0xff, 0 | 229 | #define SR_IEEE_ADDR_1 0x25, 0xff, 0 |
228 | #define RG_IEEE_ADDR_2 (0x26) | 230 | #define RG_IEEE_ADDR_2 (0x26) |
229 | #define SR_IEEE_ADDR_2 0x26, 0xff, 0 | 231 | #define SR_IEEE_ADDR_2 0x26, 0xff, 0 |
230 | #define RG_IEEE_ADDR_3 (0x27) | 232 | #define RG_IEEE_ADDR_3 (0x27) |
231 | #define SR_IEEE_ADDR_3 0x27, 0xff, 0 | 233 | #define SR_IEEE_ADDR_3 0x27, 0xff, 0 |
232 | #define RG_IEEE_ADDR_4 (0x28) | 234 | #define RG_IEEE_ADDR_4 (0x28) |
233 | #define SR_IEEE_ADDR_4 0x28, 0xff, 0 | 235 | #define SR_IEEE_ADDR_4 0x28, 0xff, 0 |
234 | #define RG_IEEE_ADDR_5 (0x29) | 236 | #define RG_IEEE_ADDR_5 (0x29) |
235 | #define SR_IEEE_ADDR_5 0x29, 0xff, 0 | 237 | #define SR_IEEE_ADDR_5 0x29, 0xff, 0 |
236 | #define RG_IEEE_ADDR_6 (0x2a) | 238 | #define RG_IEEE_ADDR_6 (0x2a) |
237 | #define SR_IEEE_ADDR_6 0x2a, 0xff, 0 | 239 | #define SR_IEEE_ADDR_6 0x2a, 0xff, 0 |
238 | #define RG_IEEE_ADDR_7 (0x2b) | 240 | #define RG_IEEE_ADDR_7 (0x2b) |
239 | #define SR_IEEE_ADDR_7 0x2b, 0xff, 0 | 241 | #define SR_IEEE_ADDR_7 0x2b, 0xff, 0 |
240 | #define RG_XAH_CTRL_0 (0x2c) | 242 | #define RG_XAH_CTRL_0 (0x2c) |
241 | #define SR_SLOTTED_OPERATION 0x2c, 0x01, 0 | 243 | #define SR_SLOTTED_OPERATION 0x2c, 0x01, 0 |
242 | #define SR_MAX_CSMA_RETRIES 0x2c, 0x0e, 1 | 244 | #define SR_MAX_CSMA_RETRIES 0x2c, 0x0e, 1 |
243 | #define SR_MAX_FRAME_RETRIES 0x2c, 0xf0, 4 | 245 | #define SR_MAX_FRAME_RETRIES 0x2c, 0xf0, 4 |
244 | #define RG_CSMA_SEED_0 (0x2d) | 246 | #define RG_CSMA_SEED_0 (0x2d) |
245 | #define SR_CSMA_SEED_0 0x2d, 0xff, 0 | 247 | #define SR_CSMA_SEED_0 0x2d, 0xff, 0 |
246 | #define RG_CSMA_SEED_1 (0x2e) | 248 | #define RG_CSMA_SEED_1 (0x2e) |
247 | #define SR_CSMA_SEED_1 0x2e, 0x07, 0 | 249 | #define SR_CSMA_SEED_1 0x2e, 0x07, 0 |
248 | #define SR_AACK_I_AM_COORD 0x2e, 0x08, 3 | 250 | #define SR_AACK_I_AM_COORD 0x2e, 0x08, 3 |
249 | #define SR_AACK_DIS_ACK 0x2e, 0x10, 4 | 251 | #define SR_AACK_DIS_ACK 0x2e, 0x10, 4 |
250 | #define SR_AACK_SET_PD 0x2e, 0x20, 5 | 252 | #define SR_AACK_SET_PD 0x2e, 0x20, 5 |
251 | #define SR_AACK_FVN_MODE 0x2e, 0xc0, 6 | 253 | #define SR_AACK_FVN_MODE 0x2e, 0xc0, 6 |
252 | #define RG_CSMA_BE (0x2f) | 254 | #define RG_CSMA_BE (0x2f) |
253 | #define SR_MIN_BE 0x2f, 0x0f, 0 | 255 | #define SR_MIN_BE 0x2f, 0x0f, 0 |
254 | #define SR_MAX_BE 0x2f, 0xf0, 4 | 256 | #define SR_MAX_BE 0x2f, 0xf0, 4 |
255 | 257 | ||
256 | #define CMD_REG 0x80 | 258 | #define CMD_REG 0x80 |
257 | #define CMD_REG_MASK 0x3f | 259 | #define CMD_REG_MASK 0x3f |
@@ -292,6 +294,8 @@ struct at86rf230_local { | |||
292 | #define STATE_BUSY_RX_AACK_NOCLK 0x1E | 294 | #define STATE_BUSY_RX_AACK_NOCLK 0x1E |
293 | #define STATE_TRANSITION_IN_PROGRESS 0x1F | 295 | #define STATE_TRANSITION_IN_PROGRESS 0x1F |
294 | 296 | ||
297 | #define TRX_STATE_MASK (0x1F) | ||
298 | |||
295 | #define AT86RF2XX_NUMREGS 0x3F | 299 | #define AT86RF2XX_NUMREGS 0x3F |
296 | 300 | ||
297 | static void | 301 | static void |
@@ -336,6 +340,14 @@ at86rf230_write_subreg(struct at86rf230_local *lp, | |||
336 | return regmap_update_bits(lp->regmap, addr, mask, data << shift); | 340 | return regmap_update_bits(lp->regmap, addr, mask, data << shift); |
337 | } | 341 | } |
338 | 342 | ||
343 | static inline void | ||
344 | at86rf230_slp_tr_rising_edge(struct at86rf230_local *lp) | ||
345 | { | ||
346 | gpio_set_value(lp->slp_tr, 1); | ||
347 | udelay(1); | ||
348 | gpio_set_value(lp->slp_tr, 0); | ||
349 | } | ||
350 | |||
339 | static bool | 351 | static bool |
340 | at86rf230_reg_writeable(struct device *dev, unsigned int reg) | 352 | at86rf230_reg_writeable(struct device *dev, unsigned int reg) |
341 | { | 353 | { |
@@ -509,7 +521,7 @@ at86rf230_async_state_assert(void *context) | |||
509 | struct at86rf230_state_change *ctx = context; | 521 | struct at86rf230_state_change *ctx = context; |
510 | struct at86rf230_local *lp = ctx->lp; | 522 | struct at86rf230_local *lp = ctx->lp; |
511 | const u8 *buf = ctx->buf; | 523 | const u8 *buf = ctx->buf; |
512 | const u8 trx_state = buf[1] & 0x1f; | 524 | const u8 trx_state = buf[1] & TRX_STATE_MASK; |
513 | 525 | ||
514 | /* Assert state change */ | 526 | /* Assert state change */ |
515 | if (trx_state != ctx->to_state) { | 527 | if (trx_state != ctx->to_state) { |
@@ -609,11 +621,17 @@ at86rf230_async_state_delay(void *context) | |||
609 | switch (ctx->to_state) { | 621 | switch (ctx->to_state) { |
610 | case STATE_RX_AACK_ON: | 622 | case STATE_RX_AACK_ON: |
611 | tim = ktime_set(0, c->t_off_to_aack * NSEC_PER_USEC); | 623 | tim = ktime_set(0, c->t_off_to_aack * NSEC_PER_USEC); |
624 | /* state change from TRX_OFF to RX_AACK_ON to do a | ||
625 | * calibration, we need to reset the timeout for the | ||
626 | * next one. | ||
627 | */ | ||
628 | lp->cal_timeout = jiffies + AT86RF2XX_CAL_LOOP_TIMEOUT; | ||
612 | goto change; | 629 | goto change; |
630 | case STATE_TX_ARET_ON: | ||
613 | case STATE_TX_ON: | 631 | case STATE_TX_ON: |
614 | tim = ktime_set(0, c->t_off_to_tx_on * NSEC_PER_USEC); | 632 | tim = ktime_set(0, c->t_off_to_tx_on * NSEC_PER_USEC); |
615 | /* state change from TRX_OFF to TX_ON to do a | 633 | /* state change from TRX_OFF to TX_ON or ARET_ON to do |
616 | * calibration, we need to reset the timeout for the | 634 | * a calibration, we need to reset the timeout for the |
617 | * next one. | 635 | * next one. |
618 | */ | 636 | */ |
619 | lp->cal_timeout = jiffies + AT86RF2XX_CAL_LOOP_TIMEOUT; | 637 | lp->cal_timeout = jiffies + AT86RF2XX_CAL_LOOP_TIMEOUT; |
@@ -667,7 +685,7 @@ at86rf230_async_state_change_start(void *context) | |||
667 | struct at86rf230_state_change *ctx = context; | 685 | struct at86rf230_state_change *ctx = context; |
668 | struct at86rf230_local *lp = ctx->lp; | 686 | struct at86rf230_local *lp = ctx->lp; |
669 | u8 *buf = ctx->buf; | 687 | u8 *buf = ctx->buf; |
670 | const u8 trx_state = buf[1] & 0x1f; | 688 | const u8 trx_state = buf[1] & TRX_STATE_MASK; |
671 | int rc; | 689 | int rc; |
672 | 690 | ||
673 | /* Check for "possible" STATE_TRANSITION_IN_PROGRESS */ | 691 | /* Check for "possible" STATE_TRANSITION_IN_PROGRESS */ |
@@ -773,16 +791,6 @@ at86rf230_tx_on(void *context) | |||
773 | } | 791 | } |
774 | 792 | ||
775 | static void | 793 | static void |
776 | at86rf230_tx_trac_error(void *context) | ||
777 | { | ||
778 | struct at86rf230_state_change *ctx = context; | ||
779 | struct at86rf230_local *lp = ctx->lp; | ||
780 | |||
781 | at86rf230_async_state_change(lp, ctx, STATE_TX_ON, | ||
782 | at86rf230_tx_on, true); | ||
783 | } | ||
784 | |||
785 | static void | ||
786 | at86rf230_tx_trac_check(void *context) | 794 | at86rf230_tx_trac_check(void *context) |
787 | { | 795 | { |
788 | struct at86rf230_state_change *ctx = context; | 796 | struct at86rf230_state_change *ctx = context; |
@@ -791,12 +799,12 @@ at86rf230_tx_trac_check(void *context) | |||
791 | const u8 trac = (buf[1] & 0xe0) >> 5; | 799 | const u8 trac = (buf[1] & 0xe0) >> 5; |
792 | 800 | ||
793 | /* If trac status is different than zero we need to do a state change | 801 | /* If trac status is different than zero we need to do a state change |
794 | * to STATE_FORCE_TRX_OFF then STATE_TX_ON to recover the transceiver | 802 | * to STATE_FORCE_TRX_OFF then STATE_RX_AACK_ON to recover the |
795 | * state to TX_ON. | 803 | * transceiver. |
796 | */ | 804 | */ |
797 | if (trac) | 805 | if (trac) |
798 | at86rf230_async_state_change(lp, ctx, STATE_FORCE_TRX_OFF, | 806 | at86rf230_async_state_change(lp, ctx, STATE_FORCE_TRX_OFF, |
799 | at86rf230_tx_trac_error, true); | 807 | at86rf230_tx_on, true); |
800 | else | 808 | else |
801 | at86rf230_tx_on(context); | 809 | at86rf230_tx_on(context); |
802 | } | 810 | } |
@@ -941,13 +949,18 @@ at86rf230_write_frame_complete(void *context) | |||
941 | u8 *buf = ctx->buf; | 949 | u8 *buf = ctx->buf; |
942 | int rc; | 950 | int rc; |
943 | 951 | ||
944 | buf[0] = (RG_TRX_STATE & CMD_REG_MASK) | CMD_REG | CMD_WRITE; | ||
945 | buf[1] = STATE_BUSY_TX; | ||
946 | ctx->trx.len = 2; | 952 | ctx->trx.len = 2; |
947 | ctx->msg.complete = NULL; | 953 | |
948 | rc = spi_async(lp->spi, &ctx->msg); | 954 | if (gpio_is_valid(lp->slp_tr)) { |
949 | if (rc) | 955 | at86rf230_slp_tr_rising_edge(lp); |
950 | at86rf230_async_error(lp, ctx, rc); | 956 | } else { |
957 | buf[0] = (RG_TRX_STATE & CMD_REG_MASK) | CMD_REG | CMD_WRITE; | ||
958 | buf[1] = STATE_BUSY_TX; | ||
959 | ctx->msg.complete = NULL; | ||
960 | rc = spi_async(lp->spi, &ctx->msg); | ||
961 | if (rc) | ||
962 | at86rf230_async_error(lp, ctx, rc); | ||
963 | } | ||
951 | } | 964 | } |
952 | 965 | ||
953 | static void | 966 | static void |
@@ -993,12 +1006,21 @@ at86rf230_xmit_start(void *context) | |||
993 | * are in STATE_TX_ON. The pfad differs here, so we change | 1006 | * are in STATE_TX_ON. The pfad differs here, so we change |
994 | * the complete handler. | 1007 | * the complete handler. |
995 | */ | 1008 | */ |
996 | if (lp->tx_aret) | 1009 | if (lp->tx_aret) { |
997 | at86rf230_async_state_change(lp, ctx, STATE_TX_ON, | 1010 | if (lp->is_tx_from_off) { |
998 | at86rf230_xmit_tx_on, false); | 1011 | lp->is_tx_from_off = false; |
999 | else | 1012 | at86rf230_async_state_change(lp, ctx, STATE_TX_ARET_ON, |
1013 | at86rf230_xmit_tx_on, | ||
1014 | false); | ||
1015 | } else { | ||
1016 | at86rf230_async_state_change(lp, ctx, STATE_TX_ON, | ||
1017 | at86rf230_xmit_tx_on, | ||
1018 | false); | ||
1019 | } | ||
1020 | } else { | ||
1000 | at86rf230_async_state_change(lp, ctx, STATE_TX_ON, | 1021 | at86rf230_async_state_change(lp, ctx, STATE_TX_ON, |
1001 | at86rf230_write_frame, false); | 1022 | at86rf230_write_frame, false); |
1023 | } | ||
1002 | } | 1024 | } |
1003 | 1025 | ||
1004 | static int | 1026 | static int |
@@ -1017,11 +1039,13 @@ at86rf230_xmit(struct ieee802154_hw *hw, struct sk_buff *skb) | |||
1017 | * to TX_ON, the lp->cal_timeout should be reinit by state_delay | 1039 | * to TX_ON, the lp->cal_timeout should be reinit by state_delay |
1018 | * function then to start in the next 5 minutes. | 1040 | * function then to start in the next 5 minutes. |
1019 | */ | 1041 | */ |
1020 | if (time_is_before_jiffies(lp->cal_timeout)) | 1042 | if (time_is_before_jiffies(lp->cal_timeout)) { |
1043 | lp->is_tx_from_off = true; | ||
1021 | at86rf230_async_state_change(lp, ctx, STATE_TRX_OFF, | 1044 | at86rf230_async_state_change(lp, ctx, STATE_TRX_OFF, |
1022 | at86rf230_xmit_start, false); | 1045 | at86rf230_xmit_start, false); |
1023 | else | 1046 | } else { |
1024 | at86rf230_xmit_start(ctx); | 1047 | at86rf230_xmit_start(ctx); |
1048 | } | ||
1025 | 1049 | ||
1026 | return 0; | 1050 | return 0; |
1027 | } | 1051 | } |
@@ -1037,9 +1061,6 @@ at86rf230_ed(struct ieee802154_hw *hw, u8 *level) | |||
1037 | static int | 1061 | static int |
1038 | at86rf230_start(struct ieee802154_hw *hw) | 1062 | at86rf230_start(struct ieee802154_hw *hw) |
1039 | { | 1063 | { |
1040 | struct at86rf230_local *lp = hw->priv; | ||
1041 | |||
1042 | lp->cal_timeout = jiffies + AT86RF2XX_CAL_LOOP_TIMEOUT; | ||
1043 | return at86rf230_sync_state_change(hw->priv, STATE_RX_AACK_ON); | 1064 | return at86rf230_sync_state_change(hw->priv, STATE_RX_AACK_ON); |
1044 | } | 1065 | } |
1045 | 1066 | ||
@@ -1673,6 +1694,7 @@ static int at86rf230_probe(struct spi_device *spi) | |||
1673 | lp = hw->priv; | 1694 | lp = hw->priv; |
1674 | lp->hw = hw; | 1695 | lp->hw = hw; |
1675 | lp->spi = spi; | 1696 | lp->spi = spi; |
1697 | lp->slp_tr = slp_tr; | ||
1676 | hw->parent = &spi->dev; | 1698 | hw->parent = &spi->dev; |
1677 | hw->vif_data_size = sizeof(*lp); | 1699 | hw->vif_data_size = sizeof(*lp); |
1678 | ieee802154_random_extended_addr(&hw->phy->perm_extended_addr); | 1700 | ieee802154_random_extended_addr(&hw->phy->perm_extended_addr); |
diff --git a/include/linux/tcp.h b/include/linux/tcp.h index 0caa3a2d4106..3b2911502a8c 100644 --- a/include/linux/tcp.h +++ b/include/linux/tcp.h | |||
@@ -145,11 +145,19 @@ struct tcp_sock { | |||
145 | * read the code and the spec side by side (and laugh ...) | 145 | * read the code and the spec side by side (and laugh ...) |
146 | * See RFC793 and RFC1122. The RFC writes these in capitals. | 146 | * See RFC793 and RFC1122. The RFC writes these in capitals. |
147 | */ | 147 | */ |
148 | u64 bytes_received; /* RFC4898 tcpEStatsAppHCThruOctetsReceived | ||
149 | * sum(delta(rcv_nxt)), or how many bytes | ||
150 | * were acked. | ||
151 | */ | ||
148 | u32 rcv_nxt; /* What we want to receive next */ | 152 | u32 rcv_nxt; /* What we want to receive next */ |
149 | u32 copied_seq; /* Head of yet unread data */ | 153 | u32 copied_seq; /* Head of yet unread data */ |
150 | u32 rcv_wup; /* rcv_nxt on last window update sent */ | 154 | u32 rcv_wup; /* rcv_nxt on last window update sent */ |
151 | u32 snd_nxt; /* Next sequence we send */ | 155 | u32 snd_nxt; /* Next sequence we send */ |
152 | 156 | ||
157 | u64 bytes_acked; /* RFC4898 tcpEStatsAppHCThruOctetsAcked | ||
158 | * sum(delta(snd_una)), or how many bytes | ||
159 | * were acked. | ||
160 | */ | ||
153 | u32 snd_una; /* First byte we want an ack for */ | 161 | u32 snd_una; /* First byte we want an ack for */ |
154 | u32 snd_sml; /* Last byte of the most recently transmitted small packet */ | 162 | u32 snd_sml; /* Last byte of the most recently transmitted small packet */ |
155 | u32 rcv_tstamp; /* timestamp of last received ACK (for keepalives) */ | 163 | u32 rcv_tstamp; /* timestamp of last received ACK (for keepalives) */ |
diff --git a/include/net/cfg802154.h b/include/net/cfg802154.h index eeda67652766..6ea16c84293b 100644 --- a/include/net/cfg802154.h +++ b/include/net/cfg802154.h | |||
@@ -30,11 +30,13 @@ struct wpan_phy_cca; | |||
30 | struct cfg802154_ops { | 30 | struct cfg802154_ops { |
31 | struct net_device * (*add_virtual_intf_deprecated)(struct wpan_phy *wpan_phy, | 31 | struct net_device * (*add_virtual_intf_deprecated)(struct wpan_phy *wpan_phy, |
32 | const char *name, | 32 | const char *name, |
33 | unsigned char name_assign_type, | ||
33 | int type); | 34 | int type); |
34 | void (*del_virtual_intf_deprecated)(struct wpan_phy *wpan_phy, | 35 | void (*del_virtual_intf_deprecated)(struct wpan_phy *wpan_phy, |
35 | struct net_device *dev); | 36 | struct net_device *dev); |
36 | int (*add_virtual_intf)(struct wpan_phy *wpan_phy, | 37 | int (*add_virtual_intf)(struct wpan_phy *wpan_phy, |
37 | const char *name, | 38 | const char *name, |
39 | unsigned char name_assign_type, | ||
38 | enum nl802154_iftype type, | 40 | enum nl802154_iftype type, |
39 | __le64 extended_addr); | 41 | __le64 extended_addr); |
40 | int (*del_virtual_intf)(struct wpan_phy *wpan_phy, | 42 | int (*del_virtual_intf)(struct wpan_phy *wpan_phy, |
diff --git a/include/net/mac802154.h b/include/net/mac802154.h index e18e7fd43f47..7df28a4c23f9 100644 --- a/include/net/mac802154.h +++ b/include/net/mac802154.h | |||
@@ -247,19 +247,109 @@ static inline void ieee802154_le64_to_be64(void *be64_dst, const void *le64_src) | |||
247 | __put_unaligned_memmove64(swab64p(le64_src), be64_dst); | 247 | __put_unaligned_memmove64(swab64p(le64_src), be64_dst); |
248 | } | 248 | } |
249 | 249 | ||
250 | /* Basic interface to register ieee802154 device */ | 250 | /** |
251 | * ieee802154_alloc_hw - Allocate a new hardware device | ||
252 | * | ||
253 | * This must be called once for each hardware device. The returned pointer | ||
254 | * must be used to refer to this device when calling other functions. | ||
255 | * mac802154 allocates a private data area for the driver pointed to by | ||
256 | * @priv in &struct ieee802154_hw, the size of this area is given as | ||
257 | * @priv_data_len. | ||
258 | * | ||
259 | * @priv_data_len: length of private data | ||
260 | * @ops: callbacks for this device | ||
261 | * | ||
262 | * Return: A pointer to the new hardware device, or %NULL on error. | ||
263 | */ | ||
251 | struct ieee802154_hw * | 264 | struct ieee802154_hw * |
252 | ieee802154_alloc_hw(size_t priv_data_len, const struct ieee802154_ops *ops); | 265 | ieee802154_alloc_hw(size_t priv_data_len, const struct ieee802154_ops *ops); |
266 | |||
267 | /** | ||
268 | * ieee802154_free_hw - free hardware descriptor | ||
269 | * | ||
270 | * This function frees everything that was allocated, including the | ||
271 | * private data for the driver. You must call ieee802154_unregister_hw() | ||
272 | * before calling this function. | ||
273 | * | ||
274 | * @hw: the hardware to free | ||
275 | */ | ||
253 | void ieee802154_free_hw(struct ieee802154_hw *hw); | 276 | void ieee802154_free_hw(struct ieee802154_hw *hw); |
277 | |||
278 | /** | ||
279 | * ieee802154_register_hw - Register hardware device | ||
280 | * | ||
281 | * You must call this function before any other functions in | ||
282 | * mac802154. Note that before a hardware can be registered, you | ||
283 | * need to fill the contained wpan_phy's information. | ||
284 | * | ||
285 | * @hw: the device to register as returned by ieee802154_alloc_hw() | ||
286 | * | ||
287 | * Return: 0 on success. An error code otherwise. | ||
288 | */ | ||
254 | int ieee802154_register_hw(struct ieee802154_hw *hw); | 289 | int ieee802154_register_hw(struct ieee802154_hw *hw); |
290 | |||
291 | /** | ||
292 | * ieee802154_unregister_hw - Unregister a hardware device | ||
293 | * | ||
294 | * This function instructs mac802154 to free allocated resources | ||
295 | * and unregister netdevices from the networking subsystem. | ||
296 | * | ||
297 | * @hw: the hardware to unregister | ||
298 | */ | ||
255 | void ieee802154_unregister_hw(struct ieee802154_hw *hw); | 299 | void ieee802154_unregister_hw(struct ieee802154_hw *hw); |
256 | 300 | ||
301 | /** | ||
302 | * ieee802154_rx - receive frame | ||
303 | * | ||
304 | * Use this function to hand received frames to mac802154. The receive | ||
305 | * buffer in @skb must start with an IEEE 802.15.4 header. In case of a | ||
306 | * paged @skb is used, the driver is recommended to put the ieee802154 | ||
307 | * header of the frame on the linear part of the @skb to avoid memory | ||
308 | * allocation and/or memcpy by the stack. | ||
309 | * | ||
310 | * This function may not be called in IRQ context. Calls to this function | ||
311 | * for a single hardware must be synchronized against each other. | ||
312 | * | ||
313 | * @hw: the hardware this frame came in on | ||
314 | * @skb: the buffer to receive, owned by mac802154 after this call | ||
315 | */ | ||
257 | void ieee802154_rx(struct ieee802154_hw *hw, struct sk_buff *skb); | 316 | void ieee802154_rx(struct ieee802154_hw *hw, struct sk_buff *skb); |
317 | |||
318 | /** | ||
319 | * ieee802154_rx_irqsafe - receive frame | ||
320 | * | ||
321 | * Like ieee802154_rx() but can be called in IRQ context | ||
322 | * (internally defers to a tasklet.) | ||
323 | * | ||
324 | * @hw: the hardware this frame came in on | ||
325 | * @skb: the buffer to receive, owned by mac802154 after this call | ||
326 | * @lqi: link quality indicator | ||
327 | */ | ||
258 | void ieee802154_rx_irqsafe(struct ieee802154_hw *hw, struct sk_buff *skb, | 328 | void ieee802154_rx_irqsafe(struct ieee802154_hw *hw, struct sk_buff *skb, |
259 | u8 lqi); | 329 | u8 lqi); |
260 | 330 | /** | |
331 | * ieee802154_wake_queue - wake ieee802154 queue | ||
332 | * @hw: pointer as obtained from ieee802154_alloc_hw(). | ||
333 | * | ||
334 | * Drivers should use this function instead of netif_wake_queue. | ||
335 | */ | ||
261 | void ieee802154_wake_queue(struct ieee802154_hw *hw); | 336 | void ieee802154_wake_queue(struct ieee802154_hw *hw); |
337 | |||
338 | /** | ||
339 | * ieee802154_stop_queue - stop ieee802154 queue | ||
340 | * @hw: pointer as obtained from ieee802154_alloc_hw(). | ||
341 | * | ||
342 | * Drivers should use this function instead of netif_stop_queue. | ||
343 | */ | ||
262 | void ieee802154_stop_queue(struct ieee802154_hw *hw); | 344 | void ieee802154_stop_queue(struct ieee802154_hw *hw); |
345 | |||
346 | /** | ||
347 | * ieee802154_xmit_complete - frame transmission complete | ||
348 | * | ||
349 | * @hw: pointer as obtained from ieee802154_alloc_hw(). | ||
350 | * @skb: buffer for transmission | ||
351 | * @ifs_handling: indicate interframe space handling | ||
352 | */ | ||
263 | void ieee802154_xmit_complete(struct ieee802154_hw *hw, struct sk_buff *skb, | 353 | void ieee802154_xmit_complete(struct ieee802154_hw *hw, struct sk_buff *skb, |
264 | bool ifs_handling); | 354 | bool ifs_handling); |
265 | 355 | ||
diff --git a/include/net/tcp.h b/include/net/tcp.h index 051dc5c2802d..6d204f3f9df8 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h | |||
@@ -576,7 +576,7 @@ static inline int tcp_bound_to_half_wnd(struct tcp_sock *tp, int pktsize) | |||
576 | } | 576 | } |
577 | 577 | ||
578 | /* tcp.c */ | 578 | /* tcp.c */ |
579 | void tcp_get_info(const struct sock *, struct tcp_info *); | 579 | void tcp_get_info(struct sock *, struct tcp_info *); |
580 | 580 | ||
581 | /* Read 'sendfile()'-style from a TCP socket */ | 581 | /* Read 'sendfile()'-style from a TCP socket */ |
582 | typedef int (*sk_read_actor_t)(read_descriptor_t *, struct sk_buff *, | 582 | typedef int (*sk_read_actor_t)(read_descriptor_t *, struct sk_buff *, |
@@ -804,6 +804,8 @@ enum tcp_ca_ack_event_flags { | |||
804 | /* Requires ECN/ECT set on all packets */ | 804 | /* Requires ECN/ECT set on all packets */ |
805 | #define TCP_CONG_NEEDS_ECN 0x2 | 805 | #define TCP_CONG_NEEDS_ECN 0x2 |
806 | 806 | ||
807 | union tcp_cc_info; | ||
808 | |||
807 | struct tcp_congestion_ops { | 809 | struct tcp_congestion_ops { |
808 | struct list_head list; | 810 | struct list_head list; |
809 | u32 key; | 811 | u32 key; |
@@ -829,7 +831,8 @@ struct tcp_congestion_ops { | |||
829 | /* hook for packet ack accounting (optional) */ | 831 | /* hook for packet ack accounting (optional) */ |
830 | void (*pkts_acked)(struct sock *sk, u32 num_acked, s32 rtt_us); | 832 | void (*pkts_acked)(struct sock *sk, u32 num_acked, s32 rtt_us); |
831 | /* get info for inet_diag (optional) */ | 833 | /* get info for inet_diag (optional) */ |
832 | int (*get_info)(struct sock *sk, u32 ext, struct sk_buff *skb); | 834 | size_t (*get_info)(struct sock *sk, u32 ext, int *attr, |
835 | union tcp_cc_info *info); | ||
833 | 836 | ||
834 | char name[TCP_CA_NAME_MAX]; | 837 | char name[TCP_CA_NAME_MAX]; |
835 | struct module *owner; | 838 | struct module *owner; |
diff --git a/include/uapi/linux/inet_diag.h b/include/uapi/linux/inet_diag.h index d65c0a09efd3..c7093c75bdd6 100644 --- a/include/uapi/linux/inet_diag.h +++ b/include/uapi/linux/inet_diag.h | |||
@@ -143,4 +143,8 @@ struct tcp_dctcp_info { | |||
143 | __u32 dctcp_ab_tot; | 143 | __u32 dctcp_ab_tot; |
144 | }; | 144 | }; |
145 | 145 | ||
146 | union tcp_cc_info { | ||
147 | struct tcpvegas_info vegas; | ||
148 | struct tcp_dctcp_info dctcp; | ||
149 | }; | ||
146 | #endif /* _UAPI_INET_DIAG_H_ */ | 150 | #endif /* _UAPI_INET_DIAG_H_ */ |
diff --git a/include/uapi/linux/tcp.h b/include/uapi/linux/tcp.h index 3b9718328d8b..faa72f4fa547 100644 --- a/include/uapi/linux/tcp.h +++ b/include/uapi/linux/tcp.h | |||
@@ -112,6 +112,7 @@ enum { | |||
112 | #define TCP_FASTOPEN 23 /* Enable FastOpen on listeners */ | 112 | #define TCP_FASTOPEN 23 /* Enable FastOpen on listeners */ |
113 | #define TCP_TIMESTAMP 24 | 113 | #define TCP_TIMESTAMP 24 |
114 | #define TCP_NOTSENT_LOWAT 25 /* limit number of unsent bytes in write queue */ | 114 | #define TCP_NOTSENT_LOWAT 25 /* limit number of unsent bytes in write queue */ |
115 | #define TCP_CC_INFO 26 /* Get Congestion Control (optional) info */ | ||
115 | 116 | ||
116 | struct tcp_repair_opt { | 117 | struct tcp_repair_opt { |
117 | __u32 opt_code; | 118 | __u32 opt_code; |
@@ -189,6 +190,8 @@ struct tcp_info { | |||
189 | 190 | ||
190 | __u64 tcpi_pacing_rate; | 191 | __u64 tcpi_pacing_rate; |
191 | __u64 tcpi_max_pacing_rate; | 192 | __u64 tcpi_max_pacing_rate; |
193 | __u64 tcpi_bytes_acked; /* RFC4898 tcpEStatsAppHCThruOctetsAcked */ | ||
194 | __u64 tcpi_bytes_received; /* RFC4898 tcpEStatsAppHCThruOctetsReceived */ | ||
192 | }; | 195 | }; |
193 | 196 | ||
194 | /* for TCP_MD5SIG socket option */ | 197 | /* for TCP_MD5SIG socket option */ |
diff --git a/net/ieee802154/Makefile b/net/ieee802154/Makefile index 05dab2957cd4..4adfd4d5471b 100644 --- a/net/ieee802154/Makefile +++ b/net/ieee802154/Makefile | |||
@@ -3,7 +3,9 @@ obj-$(CONFIG_IEEE802154_SOCKET) += ieee802154_socket.o | |||
3 | obj-y += 6lowpan/ | 3 | obj-y += 6lowpan/ |
4 | 4 | ||
5 | ieee802154-y := netlink.o nl-mac.o nl-phy.o nl_policy.o core.o \ | 5 | ieee802154-y := netlink.o nl-mac.o nl-phy.o nl_policy.o core.o \ |
6 | header_ops.o sysfs.o nl802154.o | 6 | header_ops.o sysfs.o nl802154.o trace.o |
7 | ieee802154_socket-y := socket.o | 7 | ieee802154_socket-y := socket.o |
8 | 8 | ||
9 | CFLAGS_trace.o := -I$(src) | ||
10 | |||
9 | ccflags-y += -D__CHECK_ENDIAN__ | 11 | ccflags-y += -D__CHECK_ENDIAN__ |
diff --git a/net/ieee802154/nl-phy.c b/net/ieee802154/nl-phy.c index 1b9d25f6e898..346c6665d25e 100644 --- a/net/ieee802154/nl-phy.c +++ b/net/ieee802154/nl-phy.c | |||
@@ -175,6 +175,7 @@ int ieee802154_add_iface(struct sk_buff *skb, struct genl_info *info) | |||
175 | int rc = -ENOBUFS; | 175 | int rc = -ENOBUFS; |
176 | struct net_device *dev; | 176 | struct net_device *dev; |
177 | int type = __IEEE802154_DEV_INVALID; | 177 | int type = __IEEE802154_DEV_INVALID; |
178 | unsigned char name_assign_type; | ||
178 | 179 | ||
179 | pr_debug("%s\n", __func__); | 180 | pr_debug("%s\n", __func__); |
180 | 181 | ||
@@ -190,8 +191,10 @@ int ieee802154_add_iface(struct sk_buff *skb, struct genl_info *info) | |||
190 | if (devname[nla_len(info->attrs[IEEE802154_ATTR_DEV_NAME]) - 1] | 191 | if (devname[nla_len(info->attrs[IEEE802154_ATTR_DEV_NAME]) - 1] |
191 | != '\0') | 192 | != '\0') |
192 | return -EINVAL; /* phy name should be null-terminated */ | 193 | return -EINVAL; /* phy name should be null-terminated */ |
194 | name_assign_type = NET_NAME_USER; | ||
193 | } else { | 195 | } else { |
194 | devname = "wpan%d"; | 196 | devname = "wpan%d"; |
197 | name_assign_type = NET_NAME_ENUM; | ||
195 | } | 198 | } |
196 | 199 | ||
197 | if (strlen(devname) >= IFNAMSIZ) | 200 | if (strlen(devname) >= IFNAMSIZ) |
@@ -221,7 +224,7 @@ int ieee802154_add_iface(struct sk_buff *skb, struct genl_info *info) | |||
221 | } | 224 | } |
222 | 225 | ||
223 | dev = rdev_add_virtual_intf_deprecated(wpan_phy_to_rdev(phy), devname, | 226 | dev = rdev_add_virtual_intf_deprecated(wpan_phy_to_rdev(phy), devname, |
224 | type); | 227 | name_assign_type, type); |
225 | if (IS_ERR(dev)) { | 228 | if (IS_ERR(dev)) { |
226 | rc = PTR_ERR(dev); | 229 | rc = PTR_ERR(dev); |
227 | goto nla_put_failure; | 230 | goto nla_put_failure; |
diff --git a/net/ieee802154/nl802154.c b/net/ieee802154/nl802154.c index a4daf91b8d0a..f3c12f6a4a39 100644 --- a/net/ieee802154/nl802154.c +++ b/net/ieee802154/nl802154.c | |||
@@ -589,7 +589,7 @@ static int nl802154_new_interface(struct sk_buff *skb, struct genl_info *info) | |||
589 | 589 | ||
590 | return rdev_add_virtual_intf(rdev, | 590 | return rdev_add_virtual_intf(rdev, |
591 | nla_data(info->attrs[NL802154_ATTR_IFNAME]), | 591 | nla_data(info->attrs[NL802154_ATTR_IFNAME]), |
592 | type, extended_addr); | 592 | NET_NAME_USER, type, extended_addr); |
593 | } | 593 | } |
594 | 594 | ||
595 | static int nl802154_del_interface(struct sk_buff *skb, struct genl_info *info) | 595 | static int nl802154_del_interface(struct sk_buff *skb, struct genl_info *info) |
diff --git a/net/ieee802154/rdev-ops.h b/net/ieee802154/rdev-ops.h index 7c46732fad2b..7b5a9dd94fe5 100644 --- a/net/ieee802154/rdev-ops.h +++ b/net/ieee802154/rdev-ops.h | |||
@@ -4,13 +4,16 @@ | |||
4 | #include <net/cfg802154.h> | 4 | #include <net/cfg802154.h> |
5 | 5 | ||
6 | #include "core.h" | 6 | #include "core.h" |
7 | #include "trace.h" | ||
7 | 8 | ||
8 | static inline struct net_device * | 9 | static inline struct net_device * |
9 | rdev_add_virtual_intf_deprecated(struct cfg802154_registered_device *rdev, | 10 | rdev_add_virtual_intf_deprecated(struct cfg802154_registered_device *rdev, |
10 | const char *name, int type) | 11 | const char *name, |
12 | unsigned char name_assign_type, | ||
13 | int type) | ||
11 | { | 14 | { |
12 | return rdev->ops->add_virtual_intf_deprecated(&rdev->wpan_phy, name, | 15 | return rdev->ops->add_virtual_intf_deprecated(&rdev->wpan_phy, name, |
13 | type); | 16 | name_assign_type, type); |
14 | } | 17 | } |
15 | 18 | ||
16 | static inline void | 19 | static inline void |
@@ -22,75 +25,131 @@ rdev_del_virtual_intf_deprecated(struct cfg802154_registered_device *rdev, | |||
22 | 25 | ||
23 | static inline int | 26 | static inline int |
24 | rdev_add_virtual_intf(struct cfg802154_registered_device *rdev, char *name, | 27 | rdev_add_virtual_intf(struct cfg802154_registered_device *rdev, char *name, |
28 | unsigned char name_assign_type, | ||
25 | enum nl802154_iftype type, __le64 extended_addr) | 29 | enum nl802154_iftype type, __le64 extended_addr) |
26 | { | 30 | { |
27 | return rdev->ops->add_virtual_intf(&rdev->wpan_phy, name, type, | 31 | int ret; |
32 | |||
33 | trace_802154_rdev_add_virtual_intf(&rdev->wpan_phy, name, type, | ||
28 | extended_addr); | 34 | extended_addr); |
35 | ret = rdev->ops->add_virtual_intf(&rdev->wpan_phy, name, | ||
36 | name_assign_type, type, | ||
37 | extended_addr); | ||
38 | trace_802154_rdev_return_int(&rdev->wpan_phy, ret); | ||
39 | return ret; | ||
29 | } | 40 | } |
30 | 41 | ||
31 | static inline int | 42 | static inline int |
32 | rdev_del_virtual_intf(struct cfg802154_registered_device *rdev, | 43 | rdev_del_virtual_intf(struct cfg802154_registered_device *rdev, |
33 | struct wpan_dev *wpan_dev) | 44 | struct wpan_dev *wpan_dev) |
34 | { | 45 | { |
35 | return rdev->ops->del_virtual_intf(&rdev->wpan_phy, wpan_dev); | 46 | int ret; |
47 | |||
48 | trace_802154_rdev_del_virtual_intf(&rdev->wpan_phy, wpan_dev); | ||
49 | ret = rdev->ops->del_virtual_intf(&rdev->wpan_phy, wpan_dev); | ||
50 | trace_802154_rdev_return_int(&rdev->wpan_phy, ret); | ||
51 | return ret; | ||
36 | } | 52 | } |
37 | 53 | ||
38 | static inline int | 54 | static inline int |
39 | rdev_set_channel(struct cfg802154_registered_device *rdev, u8 page, u8 channel) | 55 | rdev_set_channel(struct cfg802154_registered_device *rdev, u8 page, u8 channel) |
40 | { | 56 | { |
41 | return rdev->ops->set_channel(&rdev->wpan_phy, page, channel); | 57 | int ret; |
58 | |||
59 | trace_802154_rdev_set_channel(&rdev->wpan_phy, page, channel); | ||
60 | ret = rdev->ops->set_channel(&rdev->wpan_phy, page, channel); | ||
61 | trace_802154_rdev_return_int(&rdev->wpan_phy, ret); | ||
62 | return ret; | ||
42 | } | 63 | } |
43 | 64 | ||
44 | static inline int | 65 | static inline int |
45 | rdev_set_cca_mode(struct cfg802154_registered_device *rdev, | 66 | rdev_set_cca_mode(struct cfg802154_registered_device *rdev, |
46 | const struct wpan_phy_cca *cca) | 67 | const struct wpan_phy_cca *cca) |
47 | { | 68 | { |
48 | return rdev->ops->set_cca_mode(&rdev->wpan_phy, cca); | 69 | int ret; |
70 | |||
71 | trace_802154_rdev_set_cca_mode(&rdev->wpan_phy, cca); | ||
72 | ret = rdev->ops->set_cca_mode(&rdev->wpan_phy, cca); | ||
73 | trace_802154_rdev_return_int(&rdev->wpan_phy, ret); | ||
74 | return ret; | ||
49 | } | 75 | } |
50 | 76 | ||
51 | static inline int | 77 | static inline int |
52 | rdev_set_pan_id(struct cfg802154_registered_device *rdev, | 78 | rdev_set_pan_id(struct cfg802154_registered_device *rdev, |
53 | struct wpan_dev *wpan_dev, __le16 pan_id) | 79 | struct wpan_dev *wpan_dev, __le16 pan_id) |
54 | { | 80 | { |
55 | return rdev->ops->set_pan_id(&rdev->wpan_phy, wpan_dev, pan_id); | 81 | int ret; |
82 | |||
83 | trace_802154_rdev_set_pan_id(&rdev->wpan_phy, wpan_dev, pan_id); | ||
84 | ret = rdev->ops->set_pan_id(&rdev->wpan_phy, wpan_dev, pan_id); | ||
85 | trace_802154_rdev_return_int(&rdev->wpan_phy, ret); | ||
86 | return ret; | ||
56 | } | 87 | } |
57 | 88 | ||
58 | static inline int | 89 | static inline int |
59 | rdev_set_short_addr(struct cfg802154_registered_device *rdev, | 90 | rdev_set_short_addr(struct cfg802154_registered_device *rdev, |
60 | struct wpan_dev *wpan_dev, __le16 short_addr) | 91 | struct wpan_dev *wpan_dev, __le16 short_addr) |
61 | { | 92 | { |
62 | return rdev->ops->set_short_addr(&rdev->wpan_phy, wpan_dev, short_addr); | 93 | int ret; |
94 | |||
95 | trace_802154_rdev_set_short_addr(&rdev->wpan_phy, wpan_dev, short_addr); | ||
96 | ret = rdev->ops->set_short_addr(&rdev->wpan_phy, wpan_dev, short_addr); | ||
97 | trace_802154_rdev_return_int(&rdev->wpan_phy, ret); | ||
98 | return ret; | ||
63 | } | 99 | } |
64 | 100 | ||
65 | static inline int | 101 | static inline int |
66 | rdev_set_backoff_exponent(struct cfg802154_registered_device *rdev, | 102 | rdev_set_backoff_exponent(struct cfg802154_registered_device *rdev, |
67 | struct wpan_dev *wpan_dev, u8 min_be, u8 max_be) | 103 | struct wpan_dev *wpan_dev, u8 min_be, u8 max_be) |
68 | { | 104 | { |
69 | return rdev->ops->set_backoff_exponent(&rdev->wpan_phy, wpan_dev, | 105 | int ret; |
106 | |||
107 | trace_802154_rdev_set_backoff_exponent(&rdev->wpan_phy, wpan_dev, | ||
70 | min_be, max_be); | 108 | min_be, max_be); |
109 | ret = rdev->ops->set_backoff_exponent(&rdev->wpan_phy, wpan_dev, | ||
110 | min_be, max_be); | ||
111 | trace_802154_rdev_return_int(&rdev->wpan_phy, ret); | ||
112 | return ret; | ||
71 | } | 113 | } |
72 | 114 | ||
73 | static inline int | 115 | static inline int |
74 | rdev_set_max_csma_backoffs(struct cfg802154_registered_device *rdev, | 116 | rdev_set_max_csma_backoffs(struct cfg802154_registered_device *rdev, |
75 | struct wpan_dev *wpan_dev, u8 max_csma_backoffs) | 117 | struct wpan_dev *wpan_dev, u8 max_csma_backoffs) |
76 | { | 118 | { |
77 | return rdev->ops->set_max_csma_backoffs(&rdev->wpan_phy, wpan_dev, | 119 | int ret; |
78 | max_csma_backoffs); | 120 | |
121 | trace_802154_rdev_set_csma_backoffs(&rdev->wpan_phy, wpan_dev, | ||
122 | max_csma_backoffs); | ||
123 | ret = rdev->ops->set_max_csma_backoffs(&rdev->wpan_phy, wpan_dev, | ||
124 | max_csma_backoffs); | ||
125 | trace_802154_rdev_return_int(&rdev->wpan_phy, ret); | ||
126 | return ret; | ||
79 | } | 127 | } |
80 | 128 | ||
81 | static inline int | 129 | static inline int |
82 | rdev_set_max_frame_retries(struct cfg802154_registered_device *rdev, | 130 | rdev_set_max_frame_retries(struct cfg802154_registered_device *rdev, |
83 | struct wpan_dev *wpan_dev, s8 max_frame_retries) | 131 | struct wpan_dev *wpan_dev, s8 max_frame_retries) |
84 | { | 132 | { |
85 | return rdev->ops->set_max_frame_retries(&rdev->wpan_phy, wpan_dev, | 133 | int ret; |
134 | |||
135 | trace_802154_rdev_set_max_frame_retries(&rdev->wpan_phy, wpan_dev, | ||
86 | max_frame_retries); | 136 | max_frame_retries); |
137 | ret = rdev->ops->set_max_frame_retries(&rdev->wpan_phy, wpan_dev, | ||
138 | max_frame_retries); | ||
139 | trace_802154_rdev_return_int(&rdev->wpan_phy, ret); | ||
140 | return ret; | ||
87 | } | 141 | } |
88 | 142 | ||
89 | static inline int | 143 | static inline int |
90 | rdev_set_lbt_mode(struct cfg802154_registered_device *rdev, | 144 | rdev_set_lbt_mode(struct cfg802154_registered_device *rdev, |
91 | struct wpan_dev *wpan_dev, bool mode) | 145 | struct wpan_dev *wpan_dev, bool mode) |
92 | { | 146 | { |
93 | return rdev->ops->set_lbt_mode(&rdev->wpan_phy, wpan_dev, mode); | 147 | int ret; |
148 | |||
149 | trace_802154_rdev_set_lbt_mode(&rdev->wpan_phy, wpan_dev, mode); | ||
150 | ret = rdev->ops->set_lbt_mode(&rdev->wpan_phy, wpan_dev, mode); | ||
151 | trace_802154_rdev_return_int(&rdev->wpan_phy, ret); | ||
152 | return ret; | ||
94 | } | 153 | } |
95 | 154 | ||
96 | #endif /* __CFG802154_RDEV_OPS */ | 155 | #endif /* __CFG802154_RDEV_OPS */ |
diff --git a/net/ieee802154/trace.c b/net/ieee802154/trace.c new file mode 100644 index 000000000000..95f997fad755 --- /dev/null +++ b/net/ieee802154/trace.c | |||
@@ -0,0 +1,7 @@ | |||
1 | #include <linux/module.h> | ||
2 | |||
3 | #ifndef __CHECKER__ | ||
4 | #define CREATE_TRACE_POINTS | ||
5 | #include "trace.h" | ||
6 | |||
7 | #endif | ||
diff --git a/net/ieee802154/trace.h b/net/ieee802154/trace.h new file mode 100644 index 000000000000..5ac25eb6ed17 --- /dev/null +++ b/net/ieee802154/trace.h | |||
@@ -0,0 +1,247 @@ | |||
1 | /* Based on net/wireless/tracing.h */ | ||
2 | |||
3 | #undef TRACE_SYSTEM | ||
4 | #define TRACE_SYSTEM cfg802154 | ||
5 | |||
6 | #if !defined(__RDEV_CFG802154_OPS_TRACE) || defined(TRACE_HEADER_MULTI_READ) | ||
7 | #define __RDEV_CFG802154_OPS_TRACE | ||
8 | |||
9 | #include <linux/tracepoint.h> | ||
10 | |||
11 | #include <net/cfg802154.h> | ||
12 | |||
13 | #define MAXNAME 32 | ||
14 | #define WPAN_PHY_ENTRY __array(char, wpan_phy_name, MAXNAME) | ||
15 | #define WPAN_PHY_ASSIGN strlcpy(__entry->wpan_phy_name, \ | ||
16 | wpan_phy_name(wpan_phy), \ | ||
17 | MAXNAME) | ||
18 | #define WPAN_PHY_PR_FMT "%s" | ||
19 | #define WPAN_PHY_PR_ARG __entry->wpan_phy_name | ||
20 | |||
21 | #define WPAN_DEV_ENTRY __field(u32, identifier) | ||
22 | #define WPAN_DEV_ASSIGN (__entry->identifier) = (!IS_ERR_OR_NULL(wpan_dev) \ | ||
23 | ? wpan_dev->identifier : 0) | ||
24 | #define WPAN_DEV_PR_FMT "wpan_dev(%u)" | ||
25 | #define WPAN_DEV_PR_ARG (__entry->identifier) | ||
26 | |||
27 | #define WPAN_CCA_ENTRY __field(enum nl802154_cca_modes, cca_mode) \ | ||
28 | __field(enum nl802154_cca_opts, cca_opt) | ||
29 | #define WPAN_CCA_ASSIGN \ | ||
30 | do { \ | ||
31 | (__entry->cca_mode) = cca->mode; \ | ||
32 | (__entry->cca_opt) = cca->opt; \ | ||
33 | } while (0) | ||
34 | #define WPAN_CCA_PR_FMT "cca_mode: %d, cca_opt: %d" | ||
35 | #define WPAN_CCA_PR_ARG __entry->cca_mode, __entry->cca_opt | ||
36 | |||
37 | #define BOOL_TO_STR(bo) (bo) ? "true" : "false" | ||
38 | |||
39 | /************************************************************* | ||
40 | * rdev->ops traces * | ||
41 | *************************************************************/ | ||
42 | |||
43 | TRACE_EVENT(802154_rdev_add_virtual_intf, | ||
44 | TP_PROTO(struct wpan_phy *wpan_phy, char *name, | ||
45 | enum nl802154_iftype type, __le64 extended_addr), | ||
46 | TP_ARGS(wpan_phy, name, type, extended_addr), | ||
47 | TP_STRUCT__entry( | ||
48 | WPAN_PHY_ENTRY | ||
49 | __string(vir_intf_name, name ? name : "<noname>") | ||
50 | __field(enum nl802154_iftype, type) | ||
51 | __field(__le64, extended_addr) | ||
52 | ), | ||
53 | TP_fast_assign( | ||
54 | WPAN_PHY_ASSIGN; | ||
55 | __assign_str(vir_intf_name, name ? name : "<noname>"); | ||
56 | __entry->type = type; | ||
57 | __entry->extended_addr = extended_addr; | ||
58 | ), | ||
59 | TP_printk(WPAN_PHY_PR_FMT ", virtual intf name: %s, type: %d, ea %llx", | ||
60 | WPAN_PHY_PR_ARG, __get_str(vir_intf_name), __entry->type, | ||
61 | __le64_to_cpu(__entry->extended_addr)) | ||
62 | ); | ||
63 | |||
64 | TRACE_EVENT(802154_rdev_del_virtual_intf, | ||
65 | TP_PROTO(struct wpan_phy *wpan_phy, struct wpan_dev *wpan_dev), | ||
66 | TP_ARGS(wpan_phy, wpan_dev), | ||
67 | TP_STRUCT__entry( | ||
68 | WPAN_PHY_ENTRY | ||
69 | WPAN_DEV_ENTRY | ||
70 | ), | ||
71 | TP_fast_assign( | ||
72 | WPAN_PHY_ASSIGN; | ||
73 | WPAN_DEV_ASSIGN; | ||
74 | ), | ||
75 | TP_printk(WPAN_PHY_PR_FMT ", " WPAN_DEV_PR_FMT, WPAN_PHY_PR_ARG, | ||
76 | WPAN_DEV_PR_ARG) | ||
77 | ); | ||
78 | |||
79 | TRACE_EVENT(802154_rdev_set_channel, | ||
80 | TP_PROTO(struct wpan_phy *wpan_phy, u8 page, u8 channel), | ||
81 | TP_ARGS(wpan_phy, page, channel), | ||
82 | TP_STRUCT__entry( | ||
83 | WPAN_PHY_ENTRY | ||
84 | __field(u8, page) | ||
85 | __field(u8, channel) | ||
86 | ), | ||
87 | TP_fast_assign( | ||
88 | WPAN_PHY_ASSIGN; | ||
89 | __entry->page = page; | ||
90 | __entry->channel = channel; | ||
91 | ), | ||
92 | TP_printk(WPAN_PHY_PR_FMT ", page: %d, channel: %d", WPAN_PHY_PR_ARG, | ||
93 | __entry->page, __entry->channel) | ||
94 | ); | ||
95 | |||
96 | TRACE_EVENT(802154_rdev_set_cca_mode, | ||
97 | TP_PROTO(struct wpan_phy *wpan_phy, const struct wpan_phy_cca *cca), | ||
98 | TP_ARGS(wpan_phy, cca), | ||
99 | TP_STRUCT__entry( | ||
100 | WPAN_PHY_ENTRY | ||
101 | WPAN_CCA_ENTRY | ||
102 | ), | ||
103 | TP_fast_assign( | ||
104 | WPAN_PHY_ASSIGN; | ||
105 | WPAN_CCA_ASSIGN; | ||
106 | ), | ||
107 | TP_printk(WPAN_PHY_PR_FMT ", " WPAN_CCA_PR_FMT, WPAN_PHY_PR_ARG, | ||
108 | WPAN_CCA_PR_ARG) | ||
109 | ); | ||
110 | |||
111 | DECLARE_EVENT_CLASS(802154_le16_template, | ||
112 | TP_PROTO(struct wpan_phy *wpan_phy, struct wpan_dev *wpan_dev, | ||
113 | __le16 le16arg), | ||
114 | TP_ARGS(wpan_phy, wpan_dev, le16arg), | ||
115 | TP_STRUCT__entry( | ||
116 | WPAN_PHY_ENTRY | ||
117 | WPAN_DEV_ENTRY | ||
118 | __field(__le16, le16arg) | ||
119 | ), | ||
120 | TP_fast_assign( | ||
121 | WPAN_PHY_ASSIGN; | ||
122 | WPAN_DEV_ASSIGN; | ||
123 | __entry->le16arg = le16arg; | ||
124 | ), | ||
125 | TP_printk(WPAN_PHY_PR_FMT ", " WPAN_DEV_PR_FMT ", pan id: 0x%04x", | ||
126 | WPAN_PHY_PR_ARG, WPAN_DEV_PR_ARG, | ||
127 | __le16_to_cpu(__entry->le16arg)) | ||
128 | ); | ||
129 | |||
130 | DEFINE_EVENT(802154_le16_template, 802154_rdev_set_pan_id, | ||
131 | TP_PROTO(struct wpan_phy *wpan_phy, struct wpan_dev *wpan_dev, | ||
132 | __le16 le16arg), | ||
133 | TP_ARGS(wpan_phy, wpan_dev, le16arg) | ||
134 | ); | ||
135 | |||
136 | DEFINE_EVENT_PRINT(802154_le16_template, 802154_rdev_set_short_addr, | ||
137 | TP_PROTO(struct wpan_phy *wpan_phy, struct wpan_dev *wpan_dev, | ||
138 | __le16 le16arg), | ||
139 | TP_ARGS(wpan_phy, wpan_dev, le16arg), | ||
140 | TP_printk(WPAN_PHY_PR_FMT ", " WPAN_DEV_PR_FMT ", sa: 0x%04x", | ||
141 | WPAN_PHY_PR_ARG, WPAN_DEV_PR_ARG, | ||
142 | __le16_to_cpu(__entry->le16arg)) | ||
143 | ); | ||
144 | |||
145 | TRACE_EVENT(802154_rdev_set_backoff_exponent, | ||
146 | TP_PROTO(struct wpan_phy *wpan_phy, struct wpan_dev *wpan_dev, | ||
147 | u8 min_be, u8 max_be), | ||
148 | TP_ARGS(wpan_phy, wpan_dev, min_be, max_be), | ||
149 | TP_STRUCT__entry( | ||
150 | WPAN_PHY_ENTRY | ||
151 | WPAN_DEV_ENTRY | ||
152 | __field(u8, min_be) | ||
153 | __field(u8, max_be) | ||
154 | ), | ||
155 | TP_fast_assign( | ||
156 | WPAN_PHY_ASSIGN; | ||
157 | WPAN_DEV_ASSIGN; | ||
158 | __entry->min_be = min_be; | ||
159 | __entry->max_be = max_be; | ||
160 | ), | ||
161 | |||
162 | TP_printk(WPAN_PHY_PR_FMT ", " WPAN_DEV_PR_FMT | ||
163 | ", min be: %d, max_be: %d", WPAN_PHY_PR_ARG, | ||
164 | WPAN_DEV_PR_ARG, __entry->min_be, __entry->max_be) | ||
165 | ); | ||
166 | |||
167 | TRACE_EVENT(802154_rdev_set_csma_backoffs, | ||
168 | TP_PROTO(struct wpan_phy *wpan_phy, struct wpan_dev *wpan_dev, | ||
169 | u8 max_csma_backoffs), | ||
170 | TP_ARGS(wpan_phy, wpan_dev, max_csma_backoffs), | ||
171 | TP_STRUCT__entry( | ||
172 | WPAN_PHY_ENTRY | ||
173 | WPAN_DEV_ENTRY | ||
174 | __field(u8, max_csma_backoffs) | ||
175 | ), | ||
176 | TP_fast_assign( | ||
177 | WPAN_PHY_ASSIGN; | ||
178 | WPAN_DEV_ASSIGN; | ||
179 | __entry->max_csma_backoffs = max_csma_backoffs; | ||
180 | ), | ||
181 | |||
182 | TP_printk(WPAN_PHY_PR_FMT ", " WPAN_DEV_PR_FMT | ||
183 | ", max csma backoffs: %d", WPAN_PHY_PR_ARG, | ||
184 | WPAN_DEV_PR_ARG, __entry->max_csma_backoffs) | ||
185 | ); | ||
186 | |||
187 | TRACE_EVENT(802154_rdev_set_max_frame_retries, | ||
188 | TP_PROTO(struct wpan_phy *wpan_phy, struct wpan_dev *wpan_dev, | ||
189 | s8 max_frame_retries), | ||
190 | TP_ARGS(wpan_phy, wpan_dev, max_frame_retries), | ||
191 | TP_STRUCT__entry( | ||
192 | WPAN_PHY_ENTRY | ||
193 | WPAN_DEV_ENTRY | ||
194 | __field(s8, max_frame_retries) | ||
195 | ), | ||
196 | TP_fast_assign( | ||
197 | WPAN_PHY_ASSIGN; | ||
198 | WPAN_DEV_ASSIGN; | ||
199 | __entry->max_frame_retries = max_frame_retries; | ||
200 | ), | ||
201 | |||
202 | TP_printk(WPAN_PHY_PR_FMT ", " WPAN_DEV_PR_FMT | ||
203 | ", max frame retries: %d", WPAN_PHY_PR_ARG, | ||
204 | WPAN_DEV_PR_ARG, __entry->max_frame_retries) | ||
205 | ); | ||
206 | |||
207 | TRACE_EVENT(802154_rdev_set_lbt_mode, | ||
208 | TP_PROTO(struct wpan_phy *wpan_phy, struct wpan_dev *wpan_dev, | ||
209 | bool mode), | ||
210 | TP_ARGS(wpan_phy, wpan_dev, mode), | ||
211 | TP_STRUCT__entry( | ||
212 | WPAN_PHY_ENTRY | ||
213 | WPAN_DEV_ENTRY | ||
214 | __field(bool, mode) | ||
215 | ), | ||
216 | TP_fast_assign( | ||
217 | WPAN_PHY_ASSIGN; | ||
218 | WPAN_DEV_ASSIGN; | ||
219 | __entry->mode = mode; | ||
220 | ), | ||
221 | TP_printk(WPAN_PHY_PR_FMT ", " WPAN_DEV_PR_FMT | ||
222 | ", lbt mode: %s", WPAN_PHY_PR_ARG, | ||
223 | WPAN_DEV_PR_ARG, BOOL_TO_STR(__entry->mode)) | ||
224 | ); | ||
225 | |||
226 | TRACE_EVENT(802154_rdev_return_int, | ||
227 | TP_PROTO(struct wpan_phy *wpan_phy, int ret), | ||
228 | TP_ARGS(wpan_phy, ret), | ||
229 | TP_STRUCT__entry( | ||
230 | WPAN_PHY_ENTRY | ||
231 | __field(int, ret) | ||
232 | ), | ||
233 | TP_fast_assign( | ||
234 | WPAN_PHY_ASSIGN; | ||
235 | __entry->ret = ret; | ||
236 | ), | ||
237 | TP_printk(WPAN_PHY_PR_FMT ", returned: %d", WPAN_PHY_PR_ARG, | ||
238 | __entry->ret) | ||
239 | ); | ||
240 | |||
241 | #endif /* !__RDEV_CFG802154_OPS_TRACE || TRACE_HEADER_MULTI_READ */ | ||
242 | |||
243 | #undef TRACE_INCLUDE_PATH | ||
244 | #define TRACE_INCLUDE_PATH . | ||
245 | #undef TRACE_INCLUDE_FILE | ||
246 | #define TRACE_INCLUDE_FILE trace | ||
247 | #include <trace/define_trace.h> | ||
diff --git a/net/ipv4/inet_diag.c b/net/ipv4/inet_diag.c index bb77ebdae3b3..4d32262c7502 100644 --- a/net/ipv4/inet_diag.c +++ b/net/ipv4/inet_diag.c | |||
@@ -224,14 +224,16 @@ int inet_sk_diag_fill(struct sock *sk, struct inet_connection_sock *icsk, | |||
224 | handler->idiag_get_info(sk, r, info); | 224 | handler->idiag_get_info(sk, r, info); |
225 | 225 | ||
226 | if (sk->sk_state < TCP_TIME_WAIT) { | 226 | if (sk->sk_state < TCP_TIME_WAIT) { |
227 | int err = 0; | 227 | union tcp_cc_info info; |
228 | size_t sz = 0; | ||
229 | int attr; | ||
228 | 230 | ||
229 | rcu_read_lock(); | 231 | rcu_read_lock(); |
230 | ca_ops = READ_ONCE(icsk->icsk_ca_ops); | 232 | ca_ops = READ_ONCE(icsk->icsk_ca_ops); |
231 | if (ca_ops && ca_ops->get_info) | 233 | if (ca_ops && ca_ops->get_info) |
232 | err = ca_ops->get_info(sk, ext, skb); | 234 | sz = ca_ops->get_info(sk, ext, &attr, &info); |
233 | rcu_read_unlock(); | 235 | rcu_read_unlock(); |
234 | if (err < 0) | 236 | if (sz && nla_put(skb, attr, sz, &info) < 0) |
235 | goto errout; | 237 | goto errout; |
236 | } | 238 | } |
237 | 239 | ||
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index 8c5cd9efebbc..46efa03d2b11 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c | |||
@@ -252,6 +252,7 @@ | |||
252 | #include <linux/types.h> | 252 | #include <linux/types.h> |
253 | #include <linux/fcntl.h> | 253 | #include <linux/fcntl.h> |
254 | #include <linux/poll.h> | 254 | #include <linux/poll.h> |
255 | #include <linux/inet_diag.h> | ||
255 | #include <linux/init.h> | 256 | #include <linux/init.h> |
256 | #include <linux/fs.h> | 257 | #include <linux/fs.h> |
257 | #include <linux/skbuff.h> | 258 | #include <linux/skbuff.h> |
@@ -2592,7 +2593,7 @@ EXPORT_SYMBOL(compat_tcp_setsockopt); | |||
2592 | #endif | 2593 | #endif |
2593 | 2594 | ||
2594 | /* Return information about state of tcp endpoint in API format. */ | 2595 | /* Return information about state of tcp endpoint in API format. */ |
2595 | void tcp_get_info(const struct sock *sk, struct tcp_info *info) | 2596 | void tcp_get_info(struct sock *sk, struct tcp_info *info) |
2596 | { | 2597 | { |
2597 | const struct tcp_sock *tp = tcp_sk(sk); | 2598 | const struct tcp_sock *tp = tcp_sk(sk); |
2598 | const struct inet_connection_sock *icsk = inet_csk(sk); | 2599 | const struct inet_connection_sock *icsk = inet_csk(sk); |
@@ -2663,6 +2664,11 @@ void tcp_get_info(const struct sock *sk, struct tcp_info *info) | |||
2663 | 2664 | ||
2664 | rate = READ_ONCE(sk->sk_max_pacing_rate); | 2665 | rate = READ_ONCE(sk->sk_max_pacing_rate); |
2665 | info->tcpi_max_pacing_rate = rate != ~0U ? rate : ~0ULL; | 2666 | info->tcpi_max_pacing_rate = rate != ~0U ? rate : ~0ULL; |
2667 | |||
2668 | spin_lock_bh(&sk->sk_lock.slock); | ||
2669 | info->tcpi_bytes_acked = tp->bytes_acked; | ||
2670 | info->tcpi_bytes_received = tp->bytes_received; | ||
2671 | spin_unlock_bh(&sk->sk_lock.slock); | ||
2666 | } | 2672 | } |
2667 | EXPORT_SYMBOL_GPL(tcp_get_info); | 2673 | EXPORT_SYMBOL_GPL(tcp_get_info); |
2668 | 2674 | ||
@@ -2734,6 +2740,26 @@ static int do_tcp_getsockopt(struct sock *sk, int level, | |||
2734 | return -EFAULT; | 2740 | return -EFAULT; |
2735 | return 0; | 2741 | return 0; |
2736 | } | 2742 | } |
2743 | case TCP_CC_INFO: { | ||
2744 | const struct tcp_congestion_ops *ca_ops; | ||
2745 | union tcp_cc_info info; | ||
2746 | size_t sz = 0; | ||
2747 | int attr; | ||
2748 | |||
2749 | if (get_user(len, optlen)) | ||
2750 | return -EFAULT; | ||
2751 | |||
2752 | ca_ops = icsk->icsk_ca_ops; | ||
2753 | if (ca_ops && ca_ops->get_info) | ||
2754 | sz = ca_ops->get_info(sk, ~0U, &attr, &info); | ||
2755 | |||
2756 | len = min_t(unsigned int, len, sz); | ||
2757 | if (put_user(len, optlen)) | ||
2758 | return -EFAULT; | ||
2759 | if (copy_to_user(optval, &info, len)) | ||
2760 | return -EFAULT; | ||
2761 | return 0; | ||
2762 | } | ||
2737 | case TCP_QUICKACK: | 2763 | case TCP_QUICKACK: |
2738 | val = !icsk->icsk_ack.pingpong; | 2764 | val = !icsk->icsk_ack.pingpong; |
2739 | break; | 2765 | break; |
diff --git a/net/ipv4/tcp_dctcp.c b/net/ipv4/tcp_dctcp.c index 4376016f7fa5..4c41c1287197 100644 --- a/net/ipv4/tcp_dctcp.c +++ b/net/ipv4/tcp_dctcp.c | |||
@@ -277,7 +277,8 @@ static void dctcp_cwnd_event(struct sock *sk, enum tcp_ca_event ev) | |||
277 | } | 277 | } |
278 | } | 278 | } |
279 | 279 | ||
280 | static int dctcp_get_info(struct sock *sk, u32 ext, struct sk_buff *skb) | 280 | static size_t dctcp_get_info(struct sock *sk, u32 ext, int *attr, |
281 | union tcp_cc_info *info) | ||
281 | { | 282 | { |
282 | const struct dctcp *ca = inet_csk_ca(sk); | 283 | const struct dctcp *ca = inet_csk_ca(sk); |
283 | 284 | ||
@@ -286,18 +287,17 @@ static int dctcp_get_info(struct sock *sk, u32 ext, struct sk_buff *skb) | |||
286 | */ | 287 | */ |
287 | if (ext & (1 << (INET_DIAG_DCTCPINFO - 1)) || | 288 | if (ext & (1 << (INET_DIAG_DCTCPINFO - 1)) || |
288 | ext & (1 << (INET_DIAG_VEGASINFO - 1))) { | 289 | ext & (1 << (INET_DIAG_VEGASINFO - 1))) { |
289 | struct tcp_dctcp_info info; | 290 | memset(info, 0, sizeof(struct tcp_dctcp_info)); |
290 | |||
291 | memset(&info, 0, sizeof(info)); | ||
292 | if (inet_csk(sk)->icsk_ca_ops != &dctcp_reno) { | 291 | if (inet_csk(sk)->icsk_ca_ops != &dctcp_reno) { |
293 | info.dctcp_enabled = 1; | 292 | info->dctcp.dctcp_enabled = 1; |
294 | info.dctcp_ce_state = (u16) ca->ce_state; | 293 | info->dctcp.dctcp_ce_state = (u16) ca->ce_state; |
295 | info.dctcp_alpha = ca->dctcp_alpha; | 294 | info->dctcp.dctcp_alpha = ca->dctcp_alpha; |
296 | info.dctcp_ab_ecn = ca->acked_bytes_ecn; | 295 | info->dctcp.dctcp_ab_ecn = ca->acked_bytes_ecn; |
297 | info.dctcp_ab_tot = ca->acked_bytes_total; | 296 | info->dctcp.dctcp_ab_tot = ca->acked_bytes_total; |
298 | } | 297 | } |
299 | 298 | ||
300 | return nla_put(skb, INET_DIAG_DCTCPINFO, sizeof(info), &info); | 299 | *attr = INET_DIAG_DCTCPINFO; |
300 | return sizeof(*info); | ||
301 | } | 301 | } |
302 | return 0; | 302 | return 0; |
303 | } | 303 | } |
diff --git a/net/ipv4/tcp_fastopen.c b/net/ipv4/tcp_fastopen.c index e3d87aca6be8..3c673d5e6cff 100644 --- a/net/ipv4/tcp_fastopen.c +++ b/net/ipv4/tcp_fastopen.c | |||
@@ -206,6 +206,7 @@ static bool tcp_fastopen_create_child(struct sock *sk, | |||
206 | skb_set_owner_r(skb2, child); | 206 | skb_set_owner_r(skb2, child); |
207 | __skb_queue_tail(&child->sk_receive_queue, skb2); | 207 | __skb_queue_tail(&child->sk_receive_queue, skb2); |
208 | tp->syn_data_acked = 1; | 208 | tp->syn_data_acked = 1; |
209 | tp->bytes_received = end_seq - TCP_SKB_CB(skb)->seq - 1; | ||
209 | } else { | 210 | } else { |
210 | end_seq = TCP_SKB_CB(skb)->seq + 1; | 211 | end_seq = TCP_SKB_CB(skb)->seq + 1; |
211 | } | 212 | } |
diff --git a/net/ipv4/tcp_illinois.c b/net/ipv4/tcp_illinois.c index 67476f085e48..f71002e4db0b 100644 --- a/net/ipv4/tcp_illinois.c +++ b/net/ipv4/tcp_illinois.c | |||
@@ -300,24 +300,25 @@ static u32 tcp_illinois_ssthresh(struct sock *sk) | |||
300 | } | 300 | } |
301 | 301 | ||
302 | /* Extract info for Tcp socket info provided via netlink. */ | 302 | /* Extract info for Tcp socket info provided via netlink. */ |
303 | static int tcp_illinois_info(struct sock *sk, u32 ext, struct sk_buff *skb) | 303 | static size_t tcp_illinois_info(struct sock *sk, u32 ext, int *attr, |
304 | union tcp_cc_info *info) | ||
304 | { | 305 | { |
305 | const struct illinois *ca = inet_csk_ca(sk); | 306 | const struct illinois *ca = inet_csk_ca(sk); |
306 | 307 | ||
307 | if (ext & (1 << (INET_DIAG_VEGASINFO - 1))) { | 308 | if (ext & (1 << (INET_DIAG_VEGASINFO - 1))) { |
308 | struct tcpvegas_info info = { | 309 | info->vegas.tcpv_enabled = 1; |
309 | .tcpv_enabled = 1, | 310 | info->vegas.tcpv_rttcnt = ca->cnt_rtt; |
310 | .tcpv_rttcnt = ca->cnt_rtt, | 311 | info->vegas.tcpv_minrtt = ca->base_rtt; |
311 | .tcpv_minrtt = ca->base_rtt, | 312 | info->vegas.tcpv_rtt = 0; |
312 | }; | ||
313 | 313 | ||
314 | if (info.tcpv_rttcnt > 0) { | 314 | if (info->vegas.tcpv_rttcnt > 0) { |
315 | u64 t = ca->sum_rtt; | 315 | u64 t = ca->sum_rtt; |
316 | 316 | ||
317 | do_div(t, info.tcpv_rttcnt); | 317 | do_div(t, info->vegas.tcpv_rttcnt); |
318 | info.tcpv_rtt = t; | 318 | info->vegas.tcpv_rtt = t; |
319 | } | 319 | } |
320 | return nla_put(skb, INET_DIAG_VEGASINFO, sizeof(info), &info); | 320 | *attr = INET_DIAG_VEGASINFO; |
321 | return sizeof(struct tcpvegas_info); | ||
321 | } | 322 | } |
322 | return 0; | 323 | return 0; |
323 | } | 324 | } |
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index 3a4d9b34bed4..bc790ea9960f 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c | |||
@@ -1820,14 +1820,12 @@ advance_sp: | |||
1820 | for (j = 0; j < used_sacks; j++) | 1820 | for (j = 0; j < used_sacks; j++) |
1821 | tp->recv_sack_cache[i++] = sp[j]; | 1821 | tp->recv_sack_cache[i++] = sp[j]; |
1822 | 1822 | ||
1823 | tcp_mark_lost_retrans(sk); | ||
1824 | |||
1825 | tcp_verify_left_out(tp); | ||
1826 | |||
1827 | if ((state.reord < tp->fackets_out) && | 1823 | if ((state.reord < tp->fackets_out) && |
1828 | ((inet_csk(sk)->icsk_ca_state != TCP_CA_Loss) || tp->undo_marker)) | 1824 | ((inet_csk(sk)->icsk_ca_state != TCP_CA_Loss) || tp->undo_marker)) |
1829 | tcp_update_reordering(sk, tp->fackets_out - state.reord, 0); | 1825 | tcp_update_reordering(sk, tp->fackets_out - state.reord, 0); |
1830 | 1826 | ||
1827 | tcp_mark_lost_retrans(sk); | ||
1828 | tcp_verify_left_out(tp); | ||
1831 | out: | 1829 | out: |
1832 | 1830 | ||
1833 | #if FASTRETRANS_DEBUG > 0 | 1831 | #if FASTRETRANS_DEBUG > 0 |
@@ -3280,6 +3278,24 @@ static inline bool tcp_may_update_window(const struct tcp_sock *tp, | |||
3280 | (ack_seq == tp->snd_wl1 && nwin > tp->snd_wnd); | 3278 | (ack_seq == tp->snd_wl1 && nwin > tp->snd_wnd); |
3281 | } | 3279 | } |
3282 | 3280 | ||
3281 | /* If we update tp->snd_una, also update tp->bytes_acked */ | ||
3282 | static void tcp_snd_una_update(struct tcp_sock *tp, u32 ack) | ||
3283 | { | ||
3284 | u32 delta = ack - tp->snd_una; | ||
3285 | |||
3286 | tp->bytes_acked += delta; | ||
3287 | tp->snd_una = ack; | ||
3288 | } | ||
3289 | |||
3290 | /* If we update tp->rcv_nxt, also update tp->bytes_received */ | ||
3291 | static void tcp_rcv_nxt_update(struct tcp_sock *tp, u32 seq) | ||
3292 | { | ||
3293 | u32 delta = seq - tp->rcv_nxt; | ||
3294 | |||
3295 | tp->bytes_received += delta; | ||
3296 | tp->rcv_nxt = seq; | ||
3297 | } | ||
3298 | |||
3283 | /* Update our send window. | 3299 | /* Update our send window. |
3284 | * | 3300 | * |
3285 | * Window update algorithm, described in RFC793/RFC1122 (used in linux-2.2 | 3301 | * Window update algorithm, described in RFC793/RFC1122 (used in linux-2.2 |
@@ -3315,7 +3331,7 @@ static int tcp_ack_update_window(struct sock *sk, const struct sk_buff *skb, u32 | |||
3315 | } | 3331 | } |
3316 | } | 3332 | } |
3317 | 3333 | ||
3318 | tp->snd_una = ack; | 3334 | tcp_snd_una_update(tp, ack); |
3319 | 3335 | ||
3320 | return flag; | 3336 | return flag; |
3321 | } | 3337 | } |
@@ -3497,7 +3513,7 @@ static int tcp_ack(struct sock *sk, const struct sk_buff *skb, int flag) | |||
3497 | * Note, we use the fact that SND.UNA>=SND.WL2. | 3513 | * Note, we use the fact that SND.UNA>=SND.WL2. |
3498 | */ | 3514 | */ |
3499 | tcp_update_wl(tp, ack_seq); | 3515 | tcp_update_wl(tp, ack_seq); |
3500 | tp->snd_una = ack; | 3516 | tcp_snd_una_update(tp, ack); |
3501 | flag |= FLAG_WIN_UPDATE; | 3517 | flag |= FLAG_WIN_UPDATE; |
3502 | 3518 | ||
3503 | tcp_in_ack_event(sk, CA_ACK_WIN_UPDATE); | 3519 | tcp_in_ack_event(sk, CA_ACK_WIN_UPDATE); |
@@ -4236,7 +4252,7 @@ static void tcp_ofo_queue(struct sock *sk) | |||
4236 | 4252 | ||
4237 | tail = skb_peek_tail(&sk->sk_receive_queue); | 4253 | tail = skb_peek_tail(&sk->sk_receive_queue); |
4238 | eaten = tail && tcp_try_coalesce(sk, tail, skb, &fragstolen); | 4254 | eaten = tail && tcp_try_coalesce(sk, tail, skb, &fragstolen); |
4239 | tp->rcv_nxt = TCP_SKB_CB(skb)->end_seq; | 4255 | tcp_rcv_nxt_update(tp, TCP_SKB_CB(skb)->end_seq); |
4240 | if (!eaten) | 4256 | if (!eaten) |
4241 | __skb_queue_tail(&sk->sk_receive_queue, skb); | 4257 | __skb_queue_tail(&sk->sk_receive_queue, skb); |
4242 | if (TCP_SKB_CB(skb)->tcp_flags & TCPHDR_FIN) | 4258 | if (TCP_SKB_CB(skb)->tcp_flags & TCPHDR_FIN) |
@@ -4404,7 +4420,7 @@ static int __must_check tcp_queue_rcv(struct sock *sk, struct sk_buff *skb, int | |||
4404 | __skb_pull(skb, hdrlen); | 4420 | __skb_pull(skb, hdrlen); |
4405 | eaten = (tail && | 4421 | eaten = (tail && |
4406 | tcp_try_coalesce(sk, tail, skb, fragstolen)) ? 1 : 0; | 4422 | tcp_try_coalesce(sk, tail, skb, fragstolen)) ? 1 : 0; |
4407 | tcp_sk(sk)->rcv_nxt = TCP_SKB_CB(skb)->end_seq; | 4423 | tcp_rcv_nxt_update(tcp_sk(sk), TCP_SKB_CB(skb)->end_seq); |
4408 | if (!eaten) { | 4424 | if (!eaten) { |
4409 | __skb_queue_tail(&sk->sk_receive_queue, skb); | 4425 | __skb_queue_tail(&sk->sk_receive_queue, skb); |
4410 | skb_set_owner_r(skb, sk); | 4426 | skb_set_owner_r(skb, sk); |
@@ -4497,7 +4513,7 @@ queue_and_out: | |||
4497 | 4513 | ||
4498 | eaten = tcp_queue_rcv(sk, skb, 0, &fragstolen); | 4514 | eaten = tcp_queue_rcv(sk, skb, 0, &fragstolen); |
4499 | } | 4515 | } |
4500 | tp->rcv_nxt = TCP_SKB_CB(skb)->end_seq; | 4516 | tcp_rcv_nxt_update(tp, TCP_SKB_CB(skb)->end_seq); |
4501 | if (skb->len) | 4517 | if (skb->len) |
4502 | tcp_event_data_recv(sk, skb); | 4518 | tcp_event_data_recv(sk, skb); |
4503 | if (TCP_SKB_CB(skb)->tcp_flags & TCPHDR_FIN) | 4519 | if (TCP_SKB_CB(skb)->tcp_flags & TCPHDR_FIN) |
@@ -5245,7 +5261,7 @@ void tcp_rcv_established(struct sock *sk, struct sk_buff *skb, | |||
5245 | tcp_rcv_rtt_measure_ts(sk, skb); | 5261 | tcp_rcv_rtt_measure_ts(sk, skb); |
5246 | 5262 | ||
5247 | __skb_pull(skb, tcp_header_len); | 5263 | __skb_pull(skb, tcp_header_len); |
5248 | tp->rcv_nxt = TCP_SKB_CB(skb)->end_seq; | 5264 | tcp_rcv_nxt_update(tp, TCP_SKB_CB(skb)->end_seq); |
5249 | NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_TCPHPHITSTOUSER); | 5265 | NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_TCPHPHITSTOUSER); |
5250 | eaten = 1; | 5266 | eaten = 1; |
5251 | } | 5267 | } |
diff --git a/net/ipv4/tcp_vegas.c b/net/ipv4/tcp_vegas.c index c71a1b8f7bde..a6cea1d5e20d 100644 --- a/net/ipv4/tcp_vegas.c +++ b/net/ipv4/tcp_vegas.c | |||
@@ -286,18 +286,19 @@ static void tcp_vegas_cong_avoid(struct sock *sk, u32 ack, u32 acked) | |||
286 | } | 286 | } |
287 | 287 | ||
288 | /* Extract info for Tcp socket info provided via netlink. */ | 288 | /* Extract info for Tcp socket info provided via netlink. */ |
289 | int tcp_vegas_get_info(struct sock *sk, u32 ext, struct sk_buff *skb) | 289 | size_t tcp_vegas_get_info(struct sock *sk, u32 ext, int *attr, |
290 | union tcp_cc_info *info) | ||
290 | { | 291 | { |
291 | const struct vegas *ca = inet_csk_ca(sk); | 292 | const struct vegas *ca = inet_csk_ca(sk); |
293 | |||
292 | if (ext & (1 << (INET_DIAG_VEGASINFO - 1))) { | 294 | if (ext & (1 << (INET_DIAG_VEGASINFO - 1))) { |
293 | struct tcpvegas_info info = { | 295 | info->vegas.tcpv_enabled = ca->doing_vegas_now, |
294 | .tcpv_enabled = ca->doing_vegas_now, | 296 | info->vegas.tcpv_rttcnt = ca->cntRTT, |
295 | .tcpv_rttcnt = ca->cntRTT, | 297 | info->vegas.tcpv_rtt = ca->baseRTT, |
296 | .tcpv_rtt = ca->baseRTT, | 298 | info->vegas.tcpv_minrtt = ca->minRTT, |
297 | .tcpv_minrtt = ca->minRTT, | 299 | |
298 | }; | 300 | *attr = INET_DIAG_VEGASINFO; |
299 | 301 | return sizeof(struct tcpvegas_info); | |
300 | return nla_put(skb, INET_DIAG_VEGASINFO, sizeof(info), &info); | ||
301 | } | 302 | } |
302 | return 0; | 303 | return 0; |
303 | } | 304 | } |
diff --git a/net/ipv4/tcp_vegas.h b/net/ipv4/tcp_vegas.h index e8a6b33cc61d..ef9da5306c68 100644 --- a/net/ipv4/tcp_vegas.h +++ b/net/ipv4/tcp_vegas.h | |||
@@ -19,6 +19,7 @@ void tcp_vegas_init(struct sock *sk); | |||
19 | void tcp_vegas_state(struct sock *sk, u8 ca_state); | 19 | void tcp_vegas_state(struct sock *sk, u8 ca_state); |
20 | void tcp_vegas_pkts_acked(struct sock *sk, u32 cnt, s32 rtt_us); | 20 | void tcp_vegas_pkts_acked(struct sock *sk, u32 cnt, s32 rtt_us); |
21 | void tcp_vegas_cwnd_event(struct sock *sk, enum tcp_ca_event event); | 21 | void tcp_vegas_cwnd_event(struct sock *sk, enum tcp_ca_event event); |
22 | int tcp_vegas_get_info(struct sock *sk, u32 ext, struct sk_buff *skb); | 22 | size_t tcp_vegas_get_info(struct sock *sk, u32 ext, int *attr, |
23 | union tcp_cc_info *info); | ||
23 | 24 | ||
24 | #endif /* __TCP_VEGAS_H */ | 25 | #endif /* __TCP_VEGAS_H */ |
diff --git a/net/mac802154/cfg.c b/net/mac802154/cfg.c index 5d9f68c75e5f..70be9c799f8a 100644 --- a/net/mac802154/cfg.c +++ b/net/mac802154/cfg.c | |||
@@ -22,13 +22,14 @@ | |||
22 | 22 | ||
23 | static struct net_device * | 23 | static struct net_device * |
24 | ieee802154_add_iface_deprecated(struct wpan_phy *wpan_phy, | 24 | ieee802154_add_iface_deprecated(struct wpan_phy *wpan_phy, |
25 | const char *name, int type) | 25 | const char *name, |
26 | unsigned char name_assign_type, int type) | ||
26 | { | 27 | { |
27 | struct ieee802154_local *local = wpan_phy_priv(wpan_phy); | 28 | struct ieee802154_local *local = wpan_phy_priv(wpan_phy); |
28 | struct net_device *dev; | 29 | struct net_device *dev; |
29 | 30 | ||
30 | rtnl_lock(); | 31 | rtnl_lock(); |
31 | dev = ieee802154_if_add(local, name, type, | 32 | dev = ieee802154_if_add(local, name, name_assign_type, type, |
32 | cpu_to_le64(0x0000000000000000ULL)); | 33 | cpu_to_le64(0x0000000000000000ULL)); |
33 | rtnl_unlock(); | 34 | rtnl_unlock(); |
34 | 35 | ||
@@ -45,12 +46,14 @@ static void ieee802154_del_iface_deprecated(struct wpan_phy *wpan_phy, | |||
45 | 46 | ||
46 | static int | 47 | static int |
47 | ieee802154_add_iface(struct wpan_phy *phy, const char *name, | 48 | ieee802154_add_iface(struct wpan_phy *phy, const char *name, |
49 | unsigned char name_assign_type, | ||
48 | enum nl802154_iftype type, __le64 extended_addr) | 50 | enum nl802154_iftype type, __le64 extended_addr) |
49 | { | 51 | { |
50 | struct ieee802154_local *local = wpan_phy_priv(phy); | 52 | struct ieee802154_local *local = wpan_phy_priv(phy); |
51 | struct net_device *err; | 53 | struct net_device *err; |
52 | 54 | ||
53 | err = ieee802154_if_add(local, name, type, extended_addr); | 55 | err = ieee802154_if_add(local, name, name_assign_type, type, |
56 | extended_addr); | ||
54 | return PTR_ERR_OR_ZERO(err); | 57 | return PTR_ERR_OR_ZERO(err); |
55 | } | 58 | } |
56 | 59 | ||
diff --git a/net/mac802154/ieee802154_i.h b/net/mac802154/ieee802154_i.h index bebd70ffc7a3..127ba18386fc 100644 --- a/net/mac802154/ieee802154_i.h +++ b/net/mac802154/ieee802154_i.h | |||
@@ -182,7 +182,8 @@ void ieee802154_iface_exit(void); | |||
182 | void ieee802154_if_remove(struct ieee802154_sub_if_data *sdata); | 182 | void ieee802154_if_remove(struct ieee802154_sub_if_data *sdata); |
183 | struct net_device * | 183 | struct net_device * |
184 | ieee802154_if_add(struct ieee802154_local *local, const char *name, | 184 | ieee802154_if_add(struct ieee802154_local *local, const char *name, |
185 | enum nl802154_iftype type, __le64 extended_addr); | 185 | unsigned char name_assign_type, enum nl802154_iftype type, |
186 | __le64 extended_addr); | ||
186 | void ieee802154_remove_interfaces(struct ieee802154_local *local); | 187 | void ieee802154_remove_interfaces(struct ieee802154_local *local); |
187 | 188 | ||
188 | #endif /* __IEEE802154_I_H */ | 189 | #endif /* __IEEE802154_I_H */ |
diff --git a/net/mac802154/iface.c b/net/mac802154/iface.c index 38b56f9d9386..91b75abbd1a1 100644 --- a/net/mac802154/iface.c +++ b/net/mac802154/iface.c | |||
@@ -522,7 +522,8 @@ ieee802154_setup_sdata(struct ieee802154_sub_if_data *sdata, | |||
522 | 522 | ||
523 | struct net_device * | 523 | struct net_device * |
524 | ieee802154_if_add(struct ieee802154_local *local, const char *name, | 524 | ieee802154_if_add(struct ieee802154_local *local, const char *name, |
525 | enum nl802154_iftype type, __le64 extended_addr) | 525 | unsigned char name_assign_type, enum nl802154_iftype type, |
526 | __le64 extended_addr) | ||
526 | { | 527 | { |
527 | struct net_device *ndev = NULL; | 528 | struct net_device *ndev = NULL; |
528 | struct ieee802154_sub_if_data *sdata = NULL; | 529 | struct ieee802154_sub_if_data *sdata = NULL; |
@@ -531,7 +532,7 @@ ieee802154_if_add(struct ieee802154_local *local, const char *name, | |||
531 | ASSERT_RTNL(); | 532 | ASSERT_RTNL(); |
532 | 533 | ||
533 | ndev = alloc_netdev(sizeof(*sdata) + local->hw.vif_data_size, name, | 534 | ndev = alloc_netdev(sizeof(*sdata) + local->hw.vif_data_size, name, |
534 | NET_NAME_UNKNOWN, ieee802154_if_setup); | 535 | name_assign_type, ieee802154_if_setup); |
535 | if (!ndev) | 536 | if (!ndev) |
536 | return ERR_PTR(-ENOMEM); | 537 | return ERR_PTR(-ENOMEM); |
537 | 538 | ||
diff --git a/net/mac802154/main.c b/net/mac802154/main.c index 8500378c8318..68b9667323ec 100644 --- a/net/mac802154/main.c +++ b/net/mac802154/main.c | |||
@@ -161,7 +161,8 @@ int ieee802154_register_hw(struct ieee802154_hw *hw) | |||
161 | 161 | ||
162 | rtnl_lock(); | 162 | rtnl_lock(); |
163 | 163 | ||
164 | dev = ieee802154_if_add(local, "wpan%d", NL802154_IFTYPE_NODE, | 164 | dev = ieee802154_if_add(local, "wpan%d", NET_NAME_ENUM, |
165 | NL802154_IFTYPE_NODE, | ||
165 | cpu_to_le64(0x0000000000000000ULL)); | 166 | cpu_to_le64(0x0000000000000000ULL)); |
166 | if (IS_ERR(dev)) { | 167 | if (IS_ERR(dev)) { |
167 | rtnl_unlock(); | 168 | rtnl_unlock(); |