Commit 73e84313 authored by David S. Miller's avatar David S. Miller

Merge branch 'for-upstream' of...

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: default avatarDavid S. Miller <davem@davemloft.net>
parents e2783717 1add1564
...@@ -227,7 +227,6 @@ static void bt3c_receive(struct bt3c_info *info) ...@@ -227,7 +227,6 @@ static void bt3c_receive(struct bt3c_info *info)
iobase = info->p_dev->resource[0]->start; iobase = info->p_dev->resource[0]->start;
avail = bt3c_read(iobase, 0x7006); avail = bt3c_read(iobase, 0x7006);
//printk("bt3c_cs: receiving %d bytes\n", avail);
bt3c_address(iobase, 0x7480); bt3c_address(iobase, 0x7480);
while (size < avail) { while (size < avail) {
...@@ -250,7 +249,6 @@ static void bt3c_receive(struct bt3c_info *info) ...@@ -250,7 +249,6 @@ static void bt3c_receive(struct bt3c_info *info)
bt_cb(info->rx_skb)->pkt_type = inb(iobase + DATA_L); bt_cb(info->rx_skb)->pkt_type = inb(iobase + DATA_L);
inb(iobase + DATA_H); inb(iobase + DATA_H);
//printk("bt3c: PACKET_TYPE=%02x\n", bt_cb(info->rx_skb)->pkt_type);
switch (bt_cb(info->rx_skb)->pkt_type) { switch (bt_cb(info->rx_skb)->pkt_type) {
...@@ -364,7 +362,6 @@ static irqreturn_t bt3c_interrupt(int irq, void *dev_inst) ...@@ -364,7 +362,6 @@ static irqreturn_t bt3c_interrupt(int irq, void *dev_inst)
if (stat & 0x0001) if (stat & 0x0001)
bt3c_receive(info); bt3c_receive(info);
if (stat & 0x0002) { if (stat & 0x0002) {
//BT_ERR("Ack (stat=0x%04x)", stat);
clear_bit(XMIT_SENDING, &(info->tx_state)); clear_bit(XMIT_SENDING, &(info->tx_state));
bt3c_write_wakeup(info); bt3c_write_wakeup(info);
} }
......
...@@ -95,6 +95,78 @@ int btbcm_set_bdaddr(struct hci_dev *hdev, const bdaddr_t *bdaddr) ...@@ -95,6 +95,78 @@ int btbcm_set_bdaddr(struct hci_dev *hdev, const bdaddr_t *bdaddr)
} }
EXPORT_SYMBOL_GPL(btbcm_set_bdaddr); EXPORT_SYMBOL_GPL(btbcm_set_bdaddr);
int btbcm_patchram(struct hci_dev *hdev, const char *firmware)
{
const struct hci_command_hdr *cmd;
const struct firmware *fw;
const u8 *fw_ptr;
size_t fw_size;
struct sk_buff *skb;
u16 opcode;
int err;
err = request_firmware(&fw, firmware, &hdev->dev);
if (err < 0) {
BT_INFO("%s: BCM: Patch %s not found", hdev->name, firmware);
return err;
}
/* Start Download */
skb = __hci_cmd_sync(hdev, 0xfc2e, 0, NULL, HCI_INIT_TIMEOUT);
if (IS_ERR(skb)) {
err = PTR_ERR(skb);
BT_ERR("%s: BCM: Download Minidrv command failed (%d)",
hdev->name, err);
goto done;
}
kfree_skb(skb);
/* 50 msec delay after Download Minidrv completes */
msleep(50);
fw_ptr = fw->data;
fw_size = fw->size;
while (fw_size >= sizeof(*cmd)) {
const u8 *cmd_param;
cmd = (struct hci_command_hdr *)fw_ptr;
fw_ptr += sizeof(*cmd);
fw_size -= sizeof(*cmd);
if (fw_size < cmd->plen) {
BT_ERR("%s: BCM: Patch %s is corrupted", hdev->name,
firmware);
err = -EINVAL;
goto done;
}
cmd_param = fw_ptr;
fw_ptr += cmd->plen;
fw_size -= cmd->plen;
opcode = le16_to_cpu(cmd->opcode);
skb = __hci_cmd_sync(hdev, opcode, cmd->plen, cmd_param,
HCI_INIT_TIMEOUT);
if (IS_ERR(skb)) {
err = PTR_ERR(skb);
BT_ERR("%s: BCM: Patch command %04x failed (%d)",
hdev->name, opcode, err);
goto done;
}
kfree_skb(skb);
}
/* 250 msec delay after Launch Ram completes */
msleep(250);
done:
release_firmware(fw);
return err;
}
EXPORT_SYMBOL(btbcm_patchram);
static int btbcm_reset(struct hci_dev *hdev) static int btbcm_reset(struct hci_dev *hdev)
{ {
struct sk_buff *skb; struct sk_buff *skb;
...@@ -198,12 +270,8 @@ static const struct { ...@@ -198,12 +270,8 @@ static const struct {
int btbcm_setup_patchram(struct hci_dev *hdev) int btbcm_setup_patchram(struct hci_dev *hdev)
{ {
const struct hci_command_hdr *cmd;
const struct firmware *fw;
const u8 *fw_ptr;
size_t fw_size;
char fw_name[64]; char fw_name[64];
u16 opcode, subver, rev, pid, vid; u16 subver, rev, pid, vid;
const char *hw_name = NULL; const char *hw_name = NULL;
struct sk_buff *skb; struct sk_buff *skb;
struct hci_rp_read_local_version *ver; struct hci_rp_read_local_version *ver;
...@@ -273,74 +341,19 @@ int btbcm_setup_patchram(struct hci_dev *hdev) ...@@ -273,74 +341,19 @@ int btbcm_setup_patchram(struct hci_dev *hdev)
hw_name ? : "BCM", (subver & 0x7000) >> 13, hw_name ? : "BCM", (subver & 0x7000) >> 13,
(subver & 0x1f00) >> 8, (subver & 0x00ff), rev & 0x0fff); (subver & 0x1f00) >> 8, (subver & 0x00ff), rev & 0x0fff);
err = request_firmware(&fw, fw_name, &hdev->dev); err = btbcm_patchram(hdev, fw_name);
if (err < 0) { if (err == -ENOENT)
BT_INFO("%s: BCM: patch %s not found", hdev->name, fw_name);
return 0; return 0;
}
/* Start Download */
skb = __hci_cmd_sync(hdev, 0xfc2e, 0, NULL, HCI_INIT_TIMEOUT);
if (IS_ERR(skb)) {
err = PTR_ERR(skb);
BT_ERR("%s: BCM: Download Minidrv command failed (%d)",
hdev->name, err);
goto reset;
}
kfree_skb(skb);
/* 50 msec delay after Download Minidrv completes */
msleep(50);
fw_ptr = fw->data;
fw_size = fw->size;
while (fw_size >= sizeof(*cmd)) {
const u8 *cmd_param;
cmd = (struct hci_command_hdr *)fw_ptr;
fw_ptr += sizeof(*cmd);
fw_size -= sizeof(*cmd);
if (fw_size < cmd->plen) {
BT_ERR("%s: BCM: patch %s is corrupted", hdev->name,
fw_name);
err = -EINVAL;
goto reset;
}
cmd_param = fw_ptr;
fw_ptr += cmd->plen;
fw_size -= cmd->plen;
opcode = le16_to_cpu(cmd->opcode);
skb = __hci_cmd_sync(hdev, opcode, cmd->plen, cmd_param,
HCI_INIT_TIMEOUT);
if (IS_ERR(skb)) {
err = PTR_ERR(skb);
BT_ERR("%s: BCM: patch command %04x failed (%d)",
hdev->name, opcode, err);
goto reset;
}
kfree_skb(skb);
}
/* 250 msec delay after Launch Ram completes */
msleep(250);
reset:
/* Reset */ /* Reset */
err = btbcm_reset(hdev); err = btbcm_reset(hdev);
if (err) if (err)
goto done; return err;
/* Read Local Version Info */ /* Read Local Version Info */
skb = btbcm_read_local_version(hdev); skb = btbcm_read_local_version(hdev);
if (IS_ERR(skb)) { if (IS_ERR(skb))
err = PTR_ERR(skb); return PTR_ERR(skb);
goto done;
}
ver = (struct hci_rp_read_local_version *)skb->data; ver = (struct hci_rp_read_local_version *)skb->data;
rev = le16_to_cpu(ver->hci_rev); rev = le16_to_cpu(ver->hci_rev);
...@@ -355,10 +368,7 @@ int btbcm_setup_patchram(struct hci_dev *hdev) ...@@ -355,10 +368,7 @@ int btbcm_setup_patchram(struct hci_dev *hdev)
set_bit(HCI_QUIRK_STRICT_DUPLICATE_FILTER, &hdev->quirks); set_bit(HCI_QUIRK_STRICT_DUPLICATE_FILTER, &hdev->quirks);
done: return 0;
release_firmware(fw);
return err;
} }
EXPORT_SYMBOL_GPL(btbcm_setup_patchram); EXPORT_SYMBOL_GPL(btbcm_setup_patchram);
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
int btbcm_check_bdaddr(struct hci_dev *hdev); int btbcm_check_bdaddr(struct hci_dev *hdev);
int btbcm_set_bdaddr(struct hci_dev *hdev, const bdaddr_t *bdaddr); int btbcm_set_bdaddr(struct hci_dev *hdev, const bdaddr_t *bdaddr);
int btbcm_patchram(struct hci_dev *hdev, const char *firmware);
int btbcm_setup_patchram(struct hci_dev *hdev); int btbcm_setup_patchram(struct hci_dev *hdev);
int btbcm_setup_apple(struct hci_dev *hdev); 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,6 +42,11 @@ static inline int btbcm_set_bdaddr(struct hci_dev *hdev, const bdaddr_t *bdaddr)
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
static inline int btbcm_patchram(struct hci_dev *hdev, const char *firmware)
{
return -EOPNOTSUPP;
}
static inline int btbcm_setup_patchram(struct hci_dev *hdev) static inline int btbcm_setup_patchram(struct hci_dev *hdev)
{ {
return 0; return 0;
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/usb.h> #include <linux/usb.h>
#include <linux/firmware.h> #include <linux/firmware.h>
#include <asm/unaligned.h>
#include <net/bluetooth/bluetooth.h> #include <net/bluetooth/bluetooth.h>
#include <net/bluetooth/hci_core.h> #include <net/bluetooth/hci_core.h>
...@@ -57,6 +58,7 @@ static struct usb_driver btusb_driver; ...@@ -57,6 +58,7 @@ static struct usb_driver btusb_driver;
#define BTUSB_AMP 0x4000 #define BTUSB_AMP 0x4000
#define BTUSB_QCA_ROME 0x8000 #define BTUSB_QCA_ROME 0x8000
#define BTUSB_BCM_APPLE 0x10000 #define BTUSB_BCM_APPLE 0x10000
#define BTUSB_REALTEK 0x20000
static const struct usb_device_id btusb_table[] = { static const struct usb_device_id btusb_table[] = {
/* Generic Bluetooth USB device */ /* Generic Bluetooth USB device */
...@@ -288,6 +290,28 @@ static const struct usb_device_id blacklist_table[] = { ...@@ -288,6 +290,28 @@ static const struct usb_device_id blacklist_table[] = {
{ USB_VENDOR_AND_INTERFACE_INFO(0x8087, 0xe0, 0x01, 0x01), { USB_VENDOR_AND_INTERFACE_INFO(0x8087, 0xe0, 0x01, 0x01),
.driver_info = BTUSB_IGNORE }, .driver_info = BTUSB_IGNORE },
/* Realtek Bluetooth devices */
{ USB_VENDOR_AND_INTERFACE_INFO(0x0bda, 0xe0, 0x01, 0x01),
.driver_info = BTUSB_REALTEK },
/* Additional Realtek 8723AE Bluetooth devices */
{ USB_DEVICE(0x0930, 0x021d), .driver_info = BTUSB_REALTEK },
{ USB_DEVICE(0x13d3, 0x3394), .driver_info = BTUSB_REALTEK },
/* Additional Realtek 8723BE Bluetooth devices */
{ USB_DEVICE(0x0489, 0xe085), .driver_info = BTUSB_REALTEK },
{ USB_DEVICE(0x0489, 0xe08b), .driver_info = BTUSB_REALTEK },
{ USB_DEVICE(0x13d3, 0x3410), .driver_info = BTUSB_REALTEK },
{ USB_DEVICE(0x13d3, 0x3416), .driver_info = BTUSB_REALTEK },
{ USB_DEVICE(0x13d3, 0x3459), .driver_info = BTUSB_REALTEK },
/* Additional Realtek 8821AE Bluetooth devices */
{ USB_DEVICE(0x0b05, 0x17dc), .driver_info = BTUSB_REALTEK },
{ USB_DEVICE(0x13d3, 0x3414), .driver_info = BTUSB_REALTEK },
{ USB_DEVICE(0x13d3, 0x3458), .driver_info = BTUSB_REALTEK },
{ USB_DEVICE(0x13d3, 0x3461), .driver_info = BTUSB_REALTEK },
{ USB_DEVICE(0x13d3, 0x3462), .driver_info = BTUSB_REALTEK },
{ } /* Terminating entry */ { } /* Terminating entry */
}; };
...@@ -892,7 +916,7 @@ static int btusb_open(struct hci_dev *hdev) ...@@ -892,7 +916,7 @@ static int btusb_open(struct hci_dev *hdev)
*/ */
if (data->setup_on_usb) { if (data->setup_on_usb) {
err = data->setup_on_usb(hdev); err = data->setup_on_usb(hdev);
if (err <0) if (err < 0)
return err; return err;
} }
...@@ -1345,6 +1369,378 @@ static int btusb_setup_csr(struct hci_dev *hdev) ...@@ -1345,6 +1369,378 @@ static int btusb_setup_csr(struct hci_dev *hdev)
return ret; return ret;
} }
#define RTL_FRAG_LEN 252
struct rtl_download_cmd {
__u8 index;
__u8 data[RTL_FRAG_LEN];
} __packed;
struct rtl_download_response {
__u8 status;
__u8 index;
} __packed;
struct rtl_rom_version_evt {
__u8 status;
__u8 version;
} __packed;
struct rtl_epatch_header {
__u8 signature[8];
__le32 fw_version;
__le16 num_patches;
} __packed;
#define RTL_EPATCH_SIGNATURE "Realtech"
#define RTL_ROM_LMP_3499 0x3499
#define RTL_ROM_LMP_8723A 0x1200
#define RTL_ROM_LMP_8723B 0x8723
#define RTL_ROM_LMP_8821A 0x8821
#define RTL_ROM_LMP_8761A 0x8761
static int rtl_read_rom_version(struct hci_dev *hdev, u8 *version)
{
struct rtl_rom_version_evt *rom_version;
struct sk_buff *skb;
int ret;
/* Read RTL ROM version command */
skb = __hci_cmd_sync(hdev, 0xfc6d, 0, NULL, HCI_INIT_TIMEOUT);
if (IS_ERR(skb)) {
BT_ERR("%s: Read ROM version failed (%ld)",
hdev->name, PTR_ERR(skb));
return PTR_ERR(skb);
}
if (skb->len != sizeof(*rom_version)) {
BT_ERR("%s: RTL version event length mismatch", hdev->name);
kfree_skb(skb);
return -EIO;
}
rom_version = (struct rtl_rom_version_evt *)skb->data;
BT_INFO("%s: rom_version status=%x version=%x",
hdev->name, rom_version->status, rom_version->version);
ret = rom_version->status;
if (ret == 0)
*version = rom_version->version;
kfree_skb(skb);
return ret;
}
static int rtl8723b_parse_firmware(struct hci_dev *hdev, u16 lmp_subver,
const struct firmware *fw,
unsigned char **_buf)
{
const u8 extension_sig[] = { 0x51, 0x04, 0xfd, 0x77 };
struct rtl_epatch_header *epatch_info;
unsigned char *buf;
int i, ret, len;
size_t min_size;
u8 opcode, length, data, rom_version = 0;
int project_id = -1;
const unsigned char *fwptr, *chip_id_base;
const unsigned char *patch_length_base, *patch_offset_base;
u32 patch_offset = 0;
u16 patch_length, num_patches;
const u16 project_id_to_lmp_subver[] = {
RTL_ROM_LMP_8723A,
RTL_ROM_LMP_8723B,
RTL_ROM_LMP_8821A,
RTL_ROM_LMP_8761A
};
ret = rtl_read_rom_version(hdev, &rom_version);
if (ret)
return -bt_to_errno(ret);
min_size = sizeof(struct rtl_epatch_header) + sizeof(extension_sig) + 3;
if (fw->size < min_size)
return -EINVAL;
fwptr = fw->data + fw->size - sizeof(extension_sig);
if (memcmp(fwptr, extension_sig, sizeof(extension_sig)) != 0) {
BT_ERR("%s: extension section signature mismatch", hdev->name);
return -EINVAL;
}
/* Loop from the end of the firmware parsing instructions, until
* we find an instruction that identifies the "project ID" for the
* hardware supported by this firwmare file.
* Once we have that, we double-check that that project_id is suitable
* for the hardware we are working with.
*/
while (fwptr >= fw->data + (sizeof(struct rtl_epatch_header) + 3)) {
opcode = *--fwptr;
length = *--fwptr;
data = *--fwptr;
BT_DBG("check op=%x len=%x data=%x", opcode, length, data);
if (opcode == 0xff) /* EOF */
break;
if (length == 0) {
BT_ERR("%s: found instruction with length 0",
hdev->name);
return -EINVAL;
}
if (opcode == 0 && length == 1) {
project_id = data;
break;
}
fwptr -= length;
}
if (project_id < 0) {
BT_ERR("%s: failed to find version instruction", hdev->name);
return -EINVAL;
}
if (project_id >= ARRAY_SIZE(project_id_to_lmp_subver)) {
BT_ERR("%s: unknown project id %d", hdev->name, project_id);
return -EINVAL;
}
if (lmp_subver != project_id_to_lmp_subver[project_id]) {
BT_ERR("%s: firmware is for %x but this is a %x", hdev->name,
project_id_to_lmp_subver[project_id], lmp_subver);
return -EINVAL;
}
epatch_info = (struct rtl_epatch_header *)fw->data;
if (memcmp(epatch_info->signature, RTL_EPATCH_SIGNATURE, 8) != 0) {
BT_ERR("%s: bad EPATCH signature", hdev->name);
return -EINVAL;
}
num_patches = le16_to_cpu(epatch_info->num_patches);
BT_DBG("fw_version=%x, num_patches=%d",
le32_to_cpu(epatch_info->fw_version), num_patches);
/* After the rtl_epatch_header there is a funky patch metadata section.
* Assuming 2 patches, the layout is:
* ChipID1 ChipID2 PatchLength1 PatchLength2 PatchOffset1 PatchOffset2
*
* Find the right patch for this chip.
*/
min_size += 8 * num_patches;
if (fw->size < min_size)
return -EINVAL;
chip_id_base = fw->data + sizeof(struct rtl_epatch_header);
patch_length_base = chip_id_base + (sizeof(u16) * num_patches);
patch_offset_base = patch_length_base + (sizeof(u16) * num_patches);
for (i = 0; i < num_patches; i++) {
u16 chip_id = get_unaligned_le16(chip_id_base +
(i * sizeof(u16)));
if (chip_id == rom_version + 1) {
patch_length = get_unaligned_le16(patch_length_base +
(i * sizeof(u16)));
patch_offset = get_unaligned_le32(patch_offset_base +
(i * sizeof(u32)));
break;
}
}
if (!patch_offset) {
BT_ERR("%s: didn't find patch for chip id %d",
hdev->name, rom_version);
return -EINVAL;
}
BT_DBG("length=%x offset=%x index %d", patch_length, patch_offset, i);
min_size = patch_offset + patch_length;
if (fw->size < min_size)
return -EINVAL;
/* Copy the firmware into a new buffer and write the version at
* the end.
*/
len = patch_length;
buf = kmemdup(fw->data + patch_offset, patch_length, GFP_KERNEL);
if (!buf)
return -ENOMEM;
memcpy(buf + patch_length - 4, &epatch_info->fw_version, 4);
*_buf = buf;
return len;
}
static int rtl_download_firmware(struct hci_dev *hdev,
const unsigned char *data, int fw_len)
{
struct rtl_download_cmd *dl_cmd;
int frag_num = fw_len / RTL_FRAG_LEN + 1;
int frag_len = RTL_FRAG_LEN;
int ret = 0;
int i;
dl_cmd = kmalloc(sizeof(struct rtl_download_cmd), GFP_KERNEL);
if (!dl_cmd)
return -ENOMEM;
for (i = 0; i < frag_num; i++) {
struct rtl_download_response *dl_resp;
struct sk_buff *skb;
BT_DBG("download fw (%d/%d)", i, frag_num);
dl_cmd->index = i;
if (i == (frag_num - 1)) {
dl_cmd->index |= 0x80; /* data end */
frag_len = fw_len % RTL_FRAG_LEN;
}
memcpy(dl_cmd->data, data, frag_len);
/* Send download command */
skb = __hci_cmd_sync(hdev, 0xfc20, frag_len + 1, dl_cmd,
HCI_INIT_TIMEOUT);
if (IS_ERR(skb)) {
BT_ERR("%s: download fw command failed (%ld)",
hdev->name, PTR_ERR(skb));
ret = -PTR_ERR(skb);
goto out;
}
if (skb->len != sizeof(*dl_resp)) {
BT_ERR("%s: download fw event length mismatch",
hdev->name);
kfree_skb(skb);
ret = -EIO;
goto out;
}
dl_resp = (struct rtl_download_response *)skb->data;
if (dl_resp->status != 0) {
kfree_skb(skb);
ret = bt_to_errno(dl_resp->status);
goto out;
}
kfree_skb(skb);
data += RTL_FRAG_LEN;
}
out:
kfree(dl_cmd);
return ret;
}
static int btusb_setup_rtl8723a(struct hci_dev *hdev)
{
struct btusb_data *data = dev_get_drvdata(&hdev->dev);
struct usb_device *udev = interface_to_usbdev(data->intf);
const struct firmware *fw;
int ret;
BT_INFO("%s: rtl: loading rtl_bt/rtl8723a_fw.bin", hdev->name);
ret = request_firmware(&fw, "rtl_bt/rtl8723a_fw.bin", &udev->dev);
if (ret < 0) {
BT_ERR("%s: Failed to load rtl_bt/rtl8723a_fw.bin", hdev->name);
return ret;
}
if (fw->size < 8) {
ret = -EINVAL;
goto out;
}
/* Check that the firmware doesn't have the epatch signature
* (which is only for RTL8723B and newer).
*/
if (!memcmp(fw->data, RTL_EPATCH_SIGNATURE, 8)) {
BT_ERR("%s: unexpected EPATCH signature!", hdev->name);
ret = -EINVAL;
goto out;
}
ret = rtl_download_firmware(hdev, fw->data, fw->size);
out:
release_firmware(fw);
return ret;
}
static int btusb_setup_rtl8723b(struct hci_dev *hdev, u16 lmp_subver,
const char *fw_name)
{
struct btusb_data *data = dev_get_drvdata(&hdev->dev);
struct usb_device *udev = interface_to_usbdev(data->intf);
unsigned char *fw_data = NULL;
const struct firmware *fw;
int ret;
BT_INFO("%s: rtl: loading %s", hdev->name, fw_name);
ret = request_firmware(&fw, fw_name, &udev->dev);
if (ret < 0) {
BT_ERR("%s: Failed to load %s", hdev->name, fw_name);
return ret;
}
ret = rtl8723b_parse_firmware(hdev, lmp_subver, fw, &fw_data);
if (ret < 0)
goto out;
ret = rtl_download_firmware(hdev, fw_data, ret);
kfree(fw_data);
if (ret < 0)
goto out;
out:
release_firmware(fw);
return ret;
}
static int btusb_setup_realtek(struct hci_dev *hdev)
{
struct sk_buff *skb;
struct hci_rp_read_local_version *resp;
u16 lmp_subver;
skb = btusb_read_local_version(hdev);
if (IS_ERR(skb))
return -PTR_ERR(skb);
resp = (struct hci_rp_read_local_version *)skb->data;
BT_INFO("%s: rtl: examining hci_ver=%02x hci_rev=%04x lmp_ver=%02x "
"lmp_subver=%04x", hdev->name, resp->hci_ver, resp->hci_rev,
resp->lmp_ver, resp->lmp_subver);
lmp_subver = le16_to_cpu(resp->lmp_subver);
kfree_skb(skb);
/* Match a set of subver values that correspond to stock firmware,
* which is not compatible with standard btusb.
* If matched, upload an alternative firmware that does conform to
* standard btusb. Once that firmware is uploaded, the subver changes
* to a different value.
*/
switch (lmp_subver) {
case RTL_ROM_LMP_8723A:
case RTL_ROM_LMP_3499:
return btusb_setup_rtl8723a(hdev);
case RTL_ROM_LMP_8723B:
return btusb_setup_rtl8723b(hdev, lmp_subver,
"rtl_bt/rtl8723b_fw.bin");
case RTL_ROM_LMP_8821A:
return btusb_setup_rtl8723b(hdev, lmp_subver,
"rtl_bt/rtl8821a_fw.bin");
case RTL_ROM_LMP_8761A:
return btusb_setup_rtl8723b(hdev, lmp_subver,
"rtl_bt/rtl8761a_fw.bin");
default:
BT_INFO("rtl: assuming no firmware upload needed.");
return 0;
}
}
static const struct firmware *btusb_setup_intel_get_fw(struct hci_dev *hdev, static const struct firmware *btusb_setup_intel_get_fw(struct hci_dev *hdev,
struct intel_version *ver) struct intel_version *ver)
{ {
...@@ -2776,6 +3172,9 @@ static int btusb_probe(struct usb_interface *intf, ...@@ -2776,6 +3172,9 @@ static int btusb_probe(struct usb_interface *intf,
hdev->set_bdaddr = btusb_set_bdaddr_ath3012; hdev->set_bdaddr = btusb_set_bdaddr_ath3012;
} }
if (id->driver_info & BTUSB_REALTEK)
hdev->setup = btusb_setup_realtek;
if (id->driver_info & BTUSB_AMP) { if (id->driver_info & BTUSB_AMP) {
/* AMP controllers do not support SCO packets */ /* AMP controllers do not support SCO packets */
data->isoc = NULL; data->isoc = NULL;
......
...@@ -95,7 +95,6 @@ static void ath_hci_uart_work(struct work_struct *work) ...@@ -95,7 +95,6 @@ static void ath_hci_uart_work(struct work_struct *work)
hci_uart_tx_wakeup(hu); hci_uart_tx_wakeup(hu);
} }
/* Initialize protocol */
static int ath_open(struct hci_uart *hu) static int ath_open(struct hci_uart *hu)
{ {
struct ath_struct *ath; struct ath_struct *ath;
...@@ -116,8 +115,7 @@ static int ath_open(struct hci_uart *hu) ...@@ -116,8 +115,7 @@ static int ath_open(struct hci_uart *hu)
return 0; return 0;
} }
/* Flush protocol data */ static int ath_close(struct hci_uart *hu)
static int ath_flush(struct hci_uart *hu)
{ {
struct ath_struct *ath = hu->priv; struct ath_struct *ath = hu->priv;
...@@ -125,11 +123,17 @@ static int ath_flush(struct hci_uart *hu) ...@@ -125,11 +123,17 @@ static int ath_flush(struct hci_uart *hu)
skb_queue_purge(&ath->txq); skb_queue_purge(&ath->txq);
kfree_skb(ath->rx_skb);
cancel_work_sync(&ath->ctxtsw);
hu->priv = NULL;
kfree(ath);
return 0; return 0;
} }
/* Close protocol */ static int ath_flush(struct hci_uart *hu)
static int ath_close(struct hci_uart *hu)
{ {
struct ath_struct *ath = hu->priv; struct ath_struct *ath = hu->priv;
...@@ -137,19 +141,65 @@ static int ath_close(struct hci_uart *hu) ...@@ -137,19 +141,65 @@ static int ath_close(struct hci_uart *hu)
skb_queue_purge(&ath->txq); skb_queue_purge(&ath->txq);
kfree_skb(ath->rx_skb); return 0;
}
cancel_work_sync(&ath->ctxtsw); static int ath_set_bdaddr(struct hci_dev *hdev, const bdaddr_t *bdaddr)
{
struct sk_buff *skb;
u8 buf[10];
int err;
buf[0] = 0x01;
buf[1] = 0x01;
buf[2] = 0x00;
buf[3] = sizeof(bdaddr_t);
memcpy(buf + 4, bdaddr, sizeof(bdaddr_t));
skb = __hci_cmd_sync(hdev, 0xfc0b, sizeof(buf), buf, HCI_INIT_TIMEOUT);
if (IS_ERR(skb)) {
err = PTR_ERR(skb);
BT_ERR("%s: Change address command failed (%d)",
hdev->name, err);
return err;
}
kfree_skb(skb);
hu->priv = NULL; return 0;
kfree(ath); }
static int ath_setup(struct hci_uart *hu)
{
BT_DBG("hu %p", hu);
hu->hdev->set_bdaddr = ath_set_bdaddr;
return 0; return 0;
} }
static const struct h4_recv_pkt ath_recv_pkts[] = {
{ H4_RECV_ACL, .recv = hci_recv_frame },
{ H4_RECV_SCO, .recv = hci_recv_frame },
{ H4_RECV_EVENT, .recv = hci_recv_frame },
};
static int ath_recv(struct hci_uart *hu, const void *data, int count)
{
struct ath_struct *ath = hu->priv;
ath->rx_skb = h4_recv_buf(hu->hdev, ath->rx_skb, data, count,
ath_recv_pkts, ARRAY_SIZE(ath_recv_pkts));
if (IS_ERR(ath->rx_skb)) {
int err = PTR_ERR(ath->rx_skb);
BT_ERR("%s: Frame reassembly failed (%d)", hu->hdev->name, err);
return err;
}
return count;
}
#define HCI_OP_ATH_SLEEP 0xFC04 #define HCI_OP_ATH_SLEEP 0xFC04
/* Enqueue frame for transmittion */
static int ath_enqueue(struct hci_uart *hu, struct sk_buff *skb) static int ath_enqueue(struct hci_uart *hu, struct sk_buff *skb)
{ {
struct ath_struct *ath = hu->priv; struct ath_struct *ath = hu->priv;
...@@ -159,8 +209,7 @@ static int ath_enqueue(struct hci_uart *hu, struct sk_buff *skb) ...@@ -159,8 +209,7 @@ static int ath_enqueue(struct hci_uart *hu, struct sk_buff *skb)
return 0; return 0;
} }
/* /* Update power management enable flag with parameters of
* Update power management enable flag with parameters of
* HCI sleep enable vendor specific HCI command. * HCI sleep enable vendor specific HCI command.
*/ */
if (bt_cb(skb)->pkt_type == HCI_COMMAND_PKT) { if (bt_cb(skb)->pkt_type == HCI_COMMAND_PKT) {
...@@ -190,37 +239,16 @@ static struct sk_buff *ath_dequeue(struct hci_uart *hu) ...@@ -190,37 +239,16 @@ static struct sk_buff *ath_dequeue(struct hci_uart *hu)
return skb_dequeue(&ath->txq); return skb_dequeue(&ath->txq);
} }
static const struct h4_recv_pkt ath_recv_pkts[] = {
{ H4_RECV_ACL, .recv = hci_recv_frame },
{ H4_RECV_SCO, .recv = hci_recv_frame },
{ H4_RECV_EVENT, .recv = hci_recv_frame },
};
/* Recv data */
static int ath_recv(struct hci_uart *hu, const void *data, int count)
{
struct ath_struct *ath = hu->priv;
ath->rx_skb = h4_recv_buf(hu->hdev, ath->rx_skb, data, count,
ath_recv_pkts, ARRAY_SIZE(ath_recv_pkts));
if (IS_ERR(ath->rx_skb)) {
int err = PTR_ERR(ath->rx_skb);
BT_ERR("%s: Frame reassembly failed (%d)", hu->hdev->name, err);
return err;
}
return count;
}
static const struct hci_uart_proto athp = { static const struct hci_uart_proto athp = {
.id = HCI_UART_ATH3K, .id = HCI_UART_ATH3K,
.name = "ATH3K", .name = "ATH3K",
.open = ath_open, .open = ath_open,
.close = ath_close, .close = ath_close,
.flush = ath_flush,
.setup = ath_setup,
.recv = ath_recv, .recv = ath_recv,
.enqueue = ath_enqueue, .enqueue = ath_enqueue,
.dequeue = ath_dequeue, .dequeue = ath_dequeue,
.flush = ath_flush,
}; };
int __init ath_init(void) int __init ath_init(void)
......
...@@ -85,6 +85,7 @@ struct at86rf230_local { ...@@ -85,6 +85,7 @@ struct at86rf230_local {
struct ieee802154_hw *hw; struct ieee802154_hw *hw;
struct at86rf2xx_chip_data *data; struct at86rf2xx_chip_data *data;
struct regmap *regmap; struct regmap *regmap;
int slp_tr;
struct completion state_complete; struct completion state_complete;
struct at86rf230_state_change state; struct at86rf230_state_change state;
...@@ -95,6 +96,7 @@ struct at86rf230_local { ...@@ -95,6 +96,7 @@ struct at86rf230_local {
unsigned long cal_timeout; unsigned long cal_timeout;
s8 max_frame_retries; s8 max_frame_retries;
bool is_tx; bool is_tx;
bool is_tx_from_off;
u8 tx_retry; u8 tx_retry;
struct sk_buff *tx_skb; struct sk_buff *tx_skb;
struct at86rf230_state_change tx; struct at86rf230_state_change tx;
...@@ -292,6 +294,8 @@ struct at86rf230_local { ...@@ -292,6 +294,8 @@ struct at86rf230_local {
#define STATE_BUSY_RX_AACK_NOCLK 0x1E #define STATE_BUSY_RX_AACK_NOCLK 0x1E
#define STATE_TRANSITION_IN_PROGRESS 0x1F #define STATE_TRANSITION_IN_PROGRESS 0x1F
#define TRX_STATE_MASK (0x1F)
#define AT86RF2XX_NUMREGS 0x3F #define AT86RF2XX_NUMREGS 0x3F
static void static void
...@@ -336,6 +340,14 @@ at86rf230_write_subreg(struct at86rf230_local *lp, ...@@ -336,6 +340,14 @@ at86rf230_write_subreg(struct at86rf230_local *lp,
return regmap_update_bits(lp->regmap, addr, mask, data << shift); return regmap_update_bits(lp->regmap, addr, mask, data << shift);
} }
static inline void
at86rf230_slp_tr_rising_edge(struct at86rf230_local *lp)
{
gpio_set_value(lp->slp_tr, 1);
udelay(1);
gpio_set_value(lp->slp_tr, 0);
}
static bool static bool
at86rf230_reg_writeable(struct device *dev, unsigned int reg) at86rf230_reg_writeable(struct device *dev, unsigned int reg)
{ {
...@@ -509,7 +521,7 @@ at86rf230_async_state_assert(void *context) ...@@ -509,7 +521,7 @@ at86rf230_async_state_assert(void *context)
struct at86rf230_state_change *ctx = context; struct at86rf230_state_change *ctx = context;
struct at86rf230_local *lp = ctx->lp; struct at86rf230_local *lp = ctx->lp;
const u8 *buf = ctx->buf; const u8 *buf = ctx->buf;
const u8 trx_state = buf[1] & 0x1f; const u8 trx_state = buf[1] & TRX_STATE_MASK;
/* Assert state change */ /* Assert state change */
if (trx_state != ctx->to_state) { if (trx_state != ctx->to_state) {
...@@ -609,11 +621,17 @@ at86rf230_async_state_delay(void *context) ...@@ -609,11 +621,17 @@ at86rf230_async_state_delay(void *context)
switch (ctx->to_state) { switch (ctx->to_state) {
case STATE_RX_AACK_ON: case STATE_RX_AACK_ON:
tim = ktime_set(0, c->t_off_to_aack * NSEC_PER_USEC); tim = ktime_set(0, c->t_off_to_aack * NSEC_PER_USEC);
/* state change from TRX_OFF to RX_AACK_ON to do a
* calibration, we need to reset the timeout for the
* next one.
*/
lp->cal_timeout = jiffies + AT86RF2XX_CAL_LOOP_TIMEOUT;
goto change; goto change;
case STATE_TX_ARET_ON:
case STATE_TX_ON: case STATE_TX_ON:
tim = ktime_set(0, c->t_off_to_tx_on * NSEC_PER_USEC); tim = ktime_set(0, c->t_off_to_tx_on * NSEC_PER_USEC);
/* state change from TRX_OFF to TX_ON to do a /* state change from TRX_OFF to TX_ON or ARET_ON to do
* calibration, we need to reset the timeout for the * a calibration, we need to reset the timeout for the
* next one. * next one.
*/ */
lp->cal_timeout = jiffies + AT86RF2XX_CAL_LOOP_TIMEOUT; lp->cal_timeout = jiffies + AT86RF2XX_CAL_LOOP_TIMEOUT;
...@@ -667,7 +685,7 @@ at86rf230_async_state_change_start(void *context) ...@@ -667,7 +685,7 @@ at86rf230_async_state_change_start(void *context)
struct at86rf230_state_change *ctx = context; struct at86rf230_state_change *ctx = context;
struct at86rf230_local *lp = ctx->lp; struct at86rf230_local *lp = ctx->lp;
u8 *buf = ctx->buf; u8 *buf = ctx->buf;
const u8 trx_state = buf[1] & 0x1f; const u8 trx_state = buf[1] & TRX_STATE_MASK;
int rc; int rc;
/* Check for "possible" STATE_TRANSITION_IN_PROGRESS */ /* Check for "possible" STATE_TRANSITION_IN_PROGRESS */
...@@ -772,16 +790,6 @@ at86rf230_tx_on(void *context) ...@@ -772,16 +790,6 @@ at86rf230_tx_on(void *context)
at86rf230_tx_complete, true); at86rf230_tx_complete, true);
} }
static void
at86rf230_tx_trac_error(void *context)
{
struct at86rf230_state_change *ctx = context;
struct at86rf230_local *lp = ctx->lp;
at86rf230_async_state_change(lp, ctx, STATE_TX_ON,
at86rf230_tx_on, true);
}
static void static void
at86rf230_tx_trac_check(void *context) at86rf230_tx_trac_check(void *context)
{ {
...@@ -791,12 +799,12 @@ at86rf230_tx_trac_check(void *context) ...@@ -791,12 +799,12 @@ at86rf230_tx_trac_check(void *context)
const u8 trac = (buf[1] & 0xe0) >> 5; const u8 trac = (buf[1] & 0xe0) >> 5;
/* If trac status is different than zero we need to do a state change /* If trac status is different than zero we need to do a state change
* to STATE_FORCE_TRX_OFF then STATE_TX_ON to recover the transceiver * to STATE_FORCE_TRX_OFF then STATE_RX_AACK_ON to recover the
* state to TX_ON. * transceiver.
*/ */
if (trac) if (trac)
at86rf230_async_state_change(lp, ctx, STATE_FORCE_TRX_OFF, at86rf230_async_state_change(lp, ctx, STATE_FORCE_TRX_OFF,
at86rf230_tx_trac_error, true); at86rf230_tx_on, true);
else else
at86rf230_tx_on(context); at86rf230_tx_on(context);
} }
...@@ -941,13 +949,18 @@ at86rf230_write_frame_complete(void *context) ...@@ -941,13 +949,18 @@ at86rf230_write_frame_complete(void *context)
u8 *buf = ctx->buf; u8 *buf = ctx->buf;
int rc; int rc;
ctx->trx.len = 2;
if (gpio_is_valid(lp->slp_tr)) {
at86rf230_slp_tr_rising_edge(lp);
} else {
buf[0] = (RG_TRX_STATE & CMD_REG_MASK) | CMD_REG | CMD_WRITE; buf[0] = (RG_TRX_STATE & CMD_REG_MASK) | CMD_REG | CMD_WRITE;
buf[1] = STATE_BUSY_TX; buf[1] = STATE_BUSY_TX;
ctx->trx.len = 2;
ctx->msg.complete = NULL; ctx->msg.complete = NULL;
rc = spi_async(lp->spi, &ctx->msg); rc = spi_async(lp->spi, &ctx->msg);
if (rc) if (rc)
at86rf230_async_error(lp, ctx, rc); at86rf230_async_error(lp, ctx, rc);
}
} }
static void static void
...@@ -993,12 +1006,21 @@ at86rf230_xmit_start(void *context) ...@@ -993,12 +1006,21 @@ at86rf230_xmit_start(void *context)
* are in STATE_TX_ON. The pfad differs here, so we change * are in STATE_TX_ON. The pfad differs here, so we change
* the complete handler. * the complete handler.
*/ */
if (lp->tx_aret) if (lp->tx_aret) {
if (lp->is_tx_from_off) {
lp->is_tx_from_off = false;
at86rf230_async_state_change(lp, ctx, STATE_TX_ARET_ON,
at86rf230_xmit_tx_on,
false);
} else {
at86rf230_async_state_change(lp, ctx, STATE_TX_ON, at86rf230_async_state_change(lp, ctx, STATE_TX_ON,
at86rf230_xmit_tx_on, false); at86rf230_xmit_tx_on,
else false);
}
} else {
at86rf230_async_state_change(lp, ctx, STATE_TX_ON, at86rf230_async_state_change(lp, ctx, STATE_TX_ON,
at86rf230_write_frame, false); at86rf230_write_frame, false);
}
} }
static int static int
...@@ -1017,11 +1039,13 @@ at86rf230_xmit(struct ieee802154_hw *hw, struct sk_buff *skb) ...@@ -1017,11 +1039,13 @@ at86rf230_xmit(struct ieee802154_hw *hw, struct sk_buff *skb)
* to TX_ON, the lp->cal_timeout should be reinit by state_delay * to TX_ON, the lp->cal_timeout should be reinit by state_delay
* function then to start in the next 5 minutes. * function then to start in the next 5 minutes.
*/ */
if (time_is_before_jiffies(lp->cal_timeout)) if (time_is_before_jiffies(lp->cal_timeout)) {
lp->is_tx_from_off = true;
at86rf230_async_state_change(lp, ctx, STATE_TRX_OFF, at86rf230_async_state_change(lp, ctx, STATE_TRX_OFF,
at86rf230_xmit_start, false); at86rf230_xmit_start, false);
else } else {
at86rf230_xmit_start(ctx); at86rf230_xmit_start(ctx);
}
return 0; return 0;
} }
...@@ -1037,9 +1061,6 @@ at86rf230_ed(struct ieee802154_hw *hw, u8 *level) ...@@ -1037,9 +1061,6 @@ at86rf230_ed(struct ieee802154_hw *hw, u8 *level)
static int static int
at86rf230_start(struct ieee802154_hw *hw) at86rf230_start(struct ieee802154_hw *hw)
{ {
struct at86rf230_local *lp = hw->priv;
lp->cal_timeout = jiffies + AT86RF2XX_CAL_LOOP_TIMEOUT;
return at86rf230_sync_state_change(hw->priv, STATE_RX_AACK_ON); return at86rf230_sync_state_change(hw->priv, STATE_RX_AACK_ON);
} }
...@@ -1673,6 +1694,7 @@ static int at86rf230_probe(struct spi_device *spi) ...@@ -1673,6 +1694,7 @@ static int at86rf230_probe(struct spi_device *spi)
lp = hw->priv; lp = hw->priv;
lp->hw = hw; lp->hw = hw;
lp->spi = spi; lp->spi = spi;
lp->slp_tr = slp_tr;
hw->parent = &spi->dev; hw->parent = &spi->dev;
hw->vif_data_size = sizeof(*lp); hw->vif_data_size = sizeof(*lp);
ieee802154_random_extended_addr(&hw->phy->perm_extended_addr); ieee802154_random_extended_addr(&hw->phy->perm_extended_addr);
......
...@@ -145,11 +145,19 @@ struct tcp_sock { ...@@ -145,11 +145,19 @@ struct tcp_sock {
* read the code and the spec side by side (and laugh ...) * read the code and the spec side by side (and laugh ...)
* See RFC793 and RFC1122. The RFC writes these in capitals. * See RFC793 and RFC1122. The RFC writes these in capitals.
*/ */
u64 bytes_received; /* RFC4898 tcpEStatsAppHCThruOctetsReceived
* sum(delta(rcv_nxt)), or how many bytes
* were acked.
*/
u32 rcv_nxt; /* What we want to receive next */ u32 rcv_nxt; /* What we want to receive next */
u32 copied_seq; /* Head of yet unread data */ u32 copied_seq; /* Head of yet unread data */
u32 rcv_wup; /* rcv_nxt on last window update sent */ u32 rcv_wup; /* rcv_nxt on last window update sent */
u32 snd_nxt; /* Next sequence we send */ u32 snd_nxt; /* Next sequence we send */
u64 bytes_acked; /* RFC4898 tcpEStatsAppHCThruOctetsAcked
* sum(delta(snd_una)), or how many bytes
* were acked.
*/
u32 snd_una; /* First byte we want an ack for */ u32 snd_una; /* First byte we want an ack for */
u32 snd_sml; /* Last byte of the most recently transmitted small packet */ u32 snd_sml; /* Last byte of the most recently transmitted small packet */
u32 rcv_tstamp; /* timestamp of last received ACK (for keepalives) */ u32 rcv_tstamp; /* timestamp of last received ACK (for keepalives) */
......
...@@ -30,11 +30,13 @@ struct wpan_phy_cca; ...@@ -30,11 +30,13 @@ struct wpan_phy_cca;
struct cfg802154_ops { struct cfg802154_ops {
struct net_device * (*add_virtual_intf_deprecated)(struct wpan_phy *wpan_phy, struct net_device * (*add_virtual_intf_deprecated)(struct wpan_phy *wpan_phy,
const char *name, const char *name,
unsigned char name_assign_type,
int type); int type);
void (*del_virtual_intf_deprecated)(struct wpan_phy *wpan_phy, void (*del_virtual_intf_deprecated)(struct wpan_phy *wpan_phy,
struct net_device *dev); struct net_device *dev);
int (*add_virtual_intf)(struct wpan_phy *wpan_phy, int (*add_virtual_intf)(struct wpan_phy *wpan_phy,
const char *name, const char *name,
unsigned char name_assign_type,
enum nl802154_iftype type, enum nl802154_iftype type,
__le64 extended_addr); __le64 extended_addr);
int (*del_virtual_intf)(struct wpan_phy *wpan_phy, int (*del_virtual_intf)(struct wpan_phy *wpan_phy,
......
...@@ -247,19 +247,109 @@ static inline void ieee802154_le64_to_be64(void *be64_dst, const void *le64_src) ...@@ -247,19 +247,109 @@ static inline void ieee802154_le64_to_be64(void *be64_dst, const void *le64_src)
__put_unaligned_memmove64(swab64p(le64_src), be64_dst); __put_unaligned_memmove64(swab64p(le64_src), be64_dst);
} }
/* Basic interface to register ieee802154 device */ /**
* ieee802154_alloc_hw - Allocate a new hardware device
*
* This must be called once for each hardware device. The returned pointer
* must be used to refer to this device when calling other functions.
* mac802154 allocates a private data area for the driver pointed to by
* @priv in &struct ieee802154_hw, the size of this area is given as
* @priv_data_len.
*
* @priv_data_len: length of private data
* @ops: callbacks for this device
*
* Return: A pointer to the new hardware device, or %NULL on error.
*/
struct ieee802154_hw * struct ieee802154_hw *
ieee802154_alloc_hw(size_t priv_data_len, const struct ieee802154_ops *ops); ieee802154_alloc_hw(size_t priv_data_len, const struct ieee802154_ops *ops);
/**
* ieee802154_free_hw - free hardware descriptor
*
* This function frees everything that was allocated, including the
* private data for the driver. You must call ieee802154_unregister_hw()
* before calling this function.
*
* @hw: the hardware to free
*/
void ieee802154_free_hw(struct ieee802154_hw *hw); void ieee802154_free_hw(struct ieee802154_hw *hw);
/**
* ieee802154_register_hw - Register hardware device
*
* You must call this function before any other functions in
* mac802154. Note that before a hardware can be registered, you
* need to fill the contained wpan_phy's information.
*
* @hw: the device to register as returned by ieee802154_alloc_hw()
*
* Return: 0 on success. An error code otherwise.
*/
int ieee802154_register_hw(struct ieee802154_hw *hw); int ieee802154_register_hw(struct ieee802154_hw *hw);
/**
* ieee802154_unregister_hw - Unregister a hardware device
*
* This function instructs mac802154 to free allocated resources
* and unregister netdevices from the networking subsystem.
*
* @hw: the hardware to unregister
*/
void ieee802154_unregister_hw(struct ieee802154_hw *hw); void ieee802154_unregister_hw(struct ieee802154_hw *hw);
/**
* ieee802154_rx - receive frame
*
* Use this function to hand received frames to mac802154. The receive
* buffer in @skb must start with an IEEE 802.15.4 header. In case of a
* paged @skb is used, the driver is recommended to put the ieee802154
* header of the frame on the linear part of the @skb to avoid memory
* allocation and/or memcpy by the stack.
*
* This function may not be called in IRQ context. Calls to this function
* for a single hardware must be synchronized against each other.
*
* @hw: the hardware this frame came in on
* @skb: the buffer to receive, owned by mac802154 after this call
*/
void ieee802154_rx(struct ieee802154_hw *hw, struct sk_buff *skb); void ieee802154_rx(struct ieee802154_hw *hw, struct sk_buff *skb);
/**
* ieee802154_rx_irqsafe - receive frame
*
* Like ieee802154_rx() but can be called in IRQ context
* (internally defers to a tasklet.)
*
* @hw: the hardware this frame came in on
* @skb: the buffer to receive, owned by mac802154 after this call
* @lqi: link quality indicator
*/
void ieee802154_rx_irqsafe(struct ieee802154_hw *hw, struct sk_buff *skb, void ieee802154_rx_irqsafe(struct ieee802154_hw *hw, struct sk_buff *skb,
u8 lqi); u8 lqi);
/**
* ieee802154_wake_queue - wake ieee802154 queue
* @hw: pointer as obtained from ieee802154_alloc_hw().
*
* Drivers should use this function instead of netif_wake_queue.
*/
void ieee802154_wake_queue(struct ieee802154_hw *hw); void ieee802154_wake_queue(struct ieee802154_hw *hw);
/**
* ieee802154_stop_queue - stop ieee802154 queue
* @hw: pointer as obtained from ieee802154_alloc_hw().
*
* Drivers should use this function instead of netif_stop_queue.
*/
void ieee802154_stop_queue(struct ieee802154_hw *hw); void ieee802154_stop_queue(struct ieee802154_hw *hw);
/**
* ieee802154_xmit_complete - frame transmission complete
*
* @hw: pointer as obtained from ieee802154_alloc_hw().
* @skb: buffer for transmission
* @ifs_handling: indicate interframe space handling
*/
void ieee802154_xmit_complete(struct ieee802154_hw *hw, struct sk_buff *skb, void ieee802154_xmit_complete(struct ieee802154_hw *hw, struct sk_buff *skb,
bool ifs_handling); bool ifs_handling);
......
...@@ -576,7 +576,7 @@ static inline int tcp_bound_to_half_wnd(struct tcp_sock *tp, int pktsize) ...@@ -576,7 +576,7 @@ static inline int tcp_bound_to_half_wnd(struct tcp_sock *tp, int pktsize)
} }
/* tcp.c */ /* tcp.c */
void tcp_get_info(const struct sock *, struct tcp_info *); void tcp_get_info(struct sock *, struct tcp_info *);
/* Read 'sendfile()'-style from a TCP socket */ /* Read 'sendfile()'-style from a TCP socket */
typedef int (*sk_read_actor_t)(read_descriptor_t *, struct sk_buff *, typedef int (*sk_read_actor_t)(read_descriptor_t *, struct sk_buff *,
...@@ -804,6 +804,8 @@ enum tcp_ca_ack_event_flags { ...@@ -804,6 +804,8 @@ enum tcp_ca_ack_event_flags {
/* Requires ECN/ECT set on all packets */ /* Requires ECN/ECT set on all packets */
#define TCP_CONG_NEEDS_ECN 0x2 #define TCP_CONG_NEEDS_ECN 0x2
union tcp_cc_info;
struct tcp_congestion_ops { struct tcp_congestion_ops {
struct list_head list; struct list_head list;
u32 key; u32 key;
...@@ -829,7 +831,8 @@ struct tcp_congestion_ops { ...@@ -829,7 +831,8 @@ struct tcp_congestion_ops {
/* hook for packet ack accounting (optional) */ /* hook for packet ack accounting (optional) */
void (*pkts_acked)(struct sock *sk, u32 num_acked, s32 rtt_us); void (*pkts_acked)(struct sock *sk, u32 num_acked, s32 rtt_us);
/* get info for inet_diag (optional) */ /* get info for inet_diag (optional) */
int (*get_info)(struct sock *sk, u32 ext, struct sk_buff *skb); size_t (*get_info)(struct sock *sk, u32 ext, int *attr,
union tcp_cc_info *info);
char name[TCP_CA_NAME_MAX]; char name[TCP_CA_NAME_MAX];
struct module *owner; struct module *owner;
......
...@@ -143,4 +143,8 @@ struct tcp_dctcp_info { ...@@ -143,4 +143,8 @@ struct tcp_dctcp_info {
__u32 dctcp_ab_tot; __u32 dctcp_ab_tot;
}; };
union tcp_cc_info {
struct tcpvegas_info vegas;
struct tcp_dctcp_info dctcp;
};
#endif /* _UAPI_INET_DIAG_H_ */ #endif /* _UAPI_INET_DIAG_H_ */
...@@ -112,6 +112,7 @@ enum { ...@@ -112,6 +112,7 @@ enum {
#define TCP_FASTOPEN 23 /* Enable FastOpen on listeners */ #define TCP_FASTOPEN 23 /* Enable FastOpen on listeners */
#define TCP_TIMESTAMP 24 #define TCP_TIMESTAMP 24
#define TCP_NOTSENT_LOWAT 25 /* limit number of unsent bytes in write queue */ #define TCP_NOTSENT_LOWAT 25 /* limit number of unsent bytes in write queue */
#define TCP_CC_INFO 26 /* Get Congestion Control (optional) info */
struct tcp_repair_opt { struct tcp_repair_opt {
__u32 opt_code; __u32 opt_code;
...@@ -189,6 +190,8 @@ struct tcp_info { ...@@ -189,6 +190,8 @@ struct tcp_info {
__u64 tcpi_pacing_rate; __u64 tcpi_pacing_rate;
__u64 tcpi_max_pacing_rate; __u64 tcpi_max_pacing_rate;
__u64 tcpi_bytes_acked; /* RFC4898 tcpEStatsAppHCThruOctetsAcked */
__u64 tcpi_bytes_received; /* RFC4898 tcpEStatsAppHCThruOctetsReceived */
}; };
/* for TCP_MD5SIG socket option */ /* for TCP_MD5SIG socket option */
......
...@@ -3,7 +3,9 @@ obj-$(CONFIG_IEEE802154_SOCKET) += ieee802154_socket.o ...@@ -3,7 +3,9 @@ obj-$(CONFIG_IEEE802154_SOCKET) += ieee802154_socket.o
obj-y += 6lowpan/ obj-y += 6lowpan/
ieee802154-y := netlink.o nl-mac.o nl-phy.o nl_policy.o core.o \ ieee802154-y := netlink.o nl-mac.o nl-phy.o nl_policy.o core.o \
header_ops.o sysfs.o nl802154.o header_ops.o sysfs.o nl802154.o trace.o
ieee802154_socket-y := socket.o ieee802154_socket-y := socket.o
CFLAGS_trace.o := -I$(src)
ccflags-y += -D__CHECK_ENDIAN__ ccflags-y += -D__CHECK_ENDIAN__
...@@ -175,6 +175,7 @@ int ieee802154_add_iface(struct sk_buff *skb, struct genl_info *info) ...@@ -175,6 +175,7 @@ int ieee802154_add_iface(struct sk_buff *skb, struct genl_info *info)
int rc = -ENOBUFS; int rc = -ENOBUFS;
struct net_device *dev; struct net_device *dev;
int type = __IEEE802154_DEV_INVALID; int type = __IEEE802154_DEV_INVALID;
unsigned char name_assign_type;
pr_debug("%s\n", __func__); pr_debug("%s\n", __func__);
...@@ -190,8 +191,10 @@ int ieee802154_add_iface(struct sk_buff *skb, struct genl_info *info) ...@@ -190,8 +191,10 @@ int ieee802154_add_iface(struct sk_buff *skb, struct genl_info *info)
if (devname[nla_len(info->attrs[IEEE802154_ATTR_DEV_NAME]) - 1] if (devname[nla_len(info->attrs[IEEE802154_ATTR_DEV_NAME]) - 1]
!= '\0') != '\0')
return -EINVAL; /* phy name should be null-terminated */ return -EINVAL; /* phy name should be null-terminated */
name_assign_type = NET_NAME_USER;
} else { } else {
devname = "wpan%d"; devname = "wpan%d";
name_assign_type = NET_NAME_ENUM;
} }
if (strlen(devname) >= IFNAMSIZ) if (strlen(devname) >= IFNAMSIZ)
...@@ -221,7 +224,7 @@ int ieee802154_add_iface(struct sk_buff *skb, struct genl_info *info) ...@@ -221,7 +224,7 @@ int ieee802154_add_iface(struct sk_buff *skb, struct genl_info *info)
} }
dev = rdev_add_virtual_intf_deprecated(wpan_phy_to_rdev(phy), devname, dev = rdev_add_virtual_intf_deprecated(wpan_phy_to_rdev(phy), devname,
type); name_assign_type, type);
if (IS_ERR(dev)) { if (IS_ERR(dev)) {
rc = PTR_ERR(dev); rc = PTR_ERR(dev);
goto nla_put_failure; goto nla_put_failure;
......
...@@ -589,7 +589,7 @@ static int nl802154_new_interface(struct sk_buff *skb, struct genl_info *info) ...@@ -589,7 +589,7 @@ static int nl802154_new_interface(struct sk_buff *skb, struct genl_info *info)
return rdev_add_virtual_intf(rdev, return rdev_add_virtual_intf(rdev,
nla_data(info->attrs[NL802154_ATTR_IFNAME]), nla_data(info->attrs[NL802154_ATTR_IFNAME]),
type, extended_addr); NET_NAME_USER, type, extended_addr);
} }
static int nl802154_del_interface(struct sk_buff *skb, struct genl_info *info) static int nl802154_del_interface(struct sk_buff *skb, struct genl_info *info)
......
...@@ -4,13 +4,16 @@ ...@@ -4,13 +4,16 @@
#include <net/cfg802154.h> #include <net/cfg802154.h>
#include "core.h" #include "core.h"
#include "trace.h"
static inline struct net_device * static inline struct net_device *
rdev_add_virtual_intf_deprecated(struct cfg802154_registered_device *rdev, rdev_add_virtual_intf_deprecated(struct cfg802154_registered_device *rdev,
const char *name, int type) const char *name,
unsigned char name_assign_type,
int type)
{ {
return rdev->ops->add_virtual_intf_deprecated(&rdev->wpan_phy, name, return rdev->ops->add_virtual_intf_deprecated(&rdev->wpan_phy, name,
type); name_assign_type, type);
} }
static inline void static inline void
...@@ -22,75 +25,131 @@ rdev_del_virtual_intf_deprecated(struct cfg802154_registered_device *rdev, ...@@ -22,75 +25,131 @@ rdev_del_virtual_intf_deprecated(struct cfg802154_registered_device *rdev,
static inline int static inline int
rdev_add_virtual_intf(struct cfg802154_registered_device *rdev, char *name, rdev_add_virtual_intf(struct cfg802154_registered_device *rdev, char *name,
unsigned char name_assign_type,
enum nl802154_iftype type, __le64 extended_addr) enum nl802154_iftype type, __le64 extended_addr)
{ {
return rdev->ops->add_virtual_intf(&rdev->wpan_phy, name, type, int ret;
trace_802154_rdev_add_virtual_intf(&rdev->wpan_phy, name, type,
extended_addr);
ret = rdev->ops->add_virtual_intf(&rdev->wpan_phy, name,
name_assign_type, type,
extended_addr); extended_addr);
trace_802154_rdev_return_int(&rdev->wpan_phy, ret);
return ret;
} }
static inline int static inline int
rdev_del_virtual_intf(struct cfg802154_registered_device *rdev, rdev_del_virtual_intf(struct cfg802154_registered_device *rdev,
struct wpan_dev *wpan_dev) struct wpan_dev *wpan_dev)
{ {
return rdev->ops->del_virtual_intf(&rdev->wpan_phy, wpan_dev); int ret;
trace_802154_rdev_del_virtual_intf(&rdev->wpan_phy, wpan_dev);
ret = rdev->ops->del_virtual_intf(&rdev->wpan_phy, wpan_dev);
trace_802154_rdev_return_int(&rdev->wpan_phy, ret);
return ret;
} }
static inline int static inline int
rdev_set_channel(struct cfg802154_registered_device *rdev, u8 page, u8 channel) rdev_set_channel(struct cfg802154_registered_device *rdev, u8 page, u8 channel)
{ {
return rdev->ops->set_channel(&rdev->wpan_phy, page, channel); int ret;
trace_802154_rdev_set_channel(&rdev->wpan_phy, page, channel);
ret = rdev->ops->set_channel(&rdev->wpan_phy, page, channel);
trace_802154_rdev_return_int(&rdev->wpan_phy, ret);
return ret;
} }
static inline int static inline int
rdev_set_cca_mode(struct cfg802154_registered_device *rdev, rdev_set_cca_mode(struct cfg802154_registered_device *rdev,
const struct wpan_phy_cca *cca) const struct wpan_phy_cca *cca)
{ {
return rdev->ops->set_cca_mode(&rdev->wpan_phy, cca); int ret;
trace_802154_rdev_set_cca_mode(&rdev->wpan_phy, cca);
ret = rdev->ops->set_cca_mode(&rdev->wpan_phy, cca);
trace_802154_rdev_return_int(&rdev->wpan_phy, ret);
return ret;
} }
static inline int static inline int
rdev_set_pan_id(struct cfg802154_registered_device *rdev, rdev_set_pan_id(struct cfg802154_registered_device *rdev,
struct wpan_dev *wpan_dev, __le16 pan_id) struct wpan_dev *wpan_dev, __le16 pan_id)
{ {
return rdev->ops->set_pan_id(&rdev->wpan_phy, wpan_dev, pan_id); int ret;
trace_802154_rdev_set_pan_id(&rdev->wpan_phy, wpan_dev, pan_id);
ret = rdev->ops->set_pan_id(&rdev->wpan_phy, wpan_dev, pan_id);
trace_802154_rdev_return_int(&rdev->wpan_phy, ret);
return ret;
} }
static inline int static inline int
rdev_set_short_addr(struct cfg802154_registered_device *rdev, rdev_set_short_addr(struct cfg802154_registered_device *rdev,
struct wpan_dev *wpan_dev, __le16 short_addr) struct wpan_dev *wpan_dev, __le16 short_addr)
{ {
return rdev->ops->set_short_addr(&rdev->wpan_phy, wpan_dev, short_addr); int ret;
trace_802154_rdev_set_short_addr(&rdev->wpan_phy, wpan_dev, short_addr);
ret = rdev->ops->set_short_addr(&rdev->wpan_phy, wpan_dev, short_addr);
trace_802154_rdev_return_int(&rdev->wpan_phy, ret);
return ret;
} }
static inline int static inline int
rdev_set_backoff_exponent(struct cfg802154_registered_device *rdev, rdev_set_backoff_exponent(struct cfg802154_registered_device *rdev,
struct wpan_dev *wpan_dev, u8 min_be, u8 max_be) struct wpan_dev *wpan_dev, u8 min_be, u8 max_be)
{ {
return rdev->ops->set_backoff_exponent(&rdev->wpan_phy, wpan_dev, int ret;
trace_802154_rdev_set_backoff_exponent(&rdev->wpan_phy, wpan_dev,
min_be, max_be);
ret = rdev->ops->set_backoff_exponent(&rdev->wpan_phy, wpan_dev,
min_be, max_be); min_be, max_be);
trace_802154_rdev_return_int(&rdev->wpan_phy, ret);
return ret;
} }
static inline int static inline int
rdev_set_max_csma_backoffs(struct cfg802154_registered_device *rdev, rdev_set_max_csma_backoffs(struct cfg802154_registered_device *rdev,
struct wpan_dev *wpan_dev, u8 max_csma_backoffs) struct wpan_dev *wpan_dev, u8 max_csma_backoffs)
{ {
return rdev->ops->set_max_csma_backoffs(&rdev->wpan_phy, wpan_dev, int ret;
trace_802154_rdev_set_csma_backoffs(&rdev->wpan_phy, wpan_dev,
max_csma_backoffs);
ret = rdev->ops->set_max_csma_backoffs(&rdev->wpan_phy, wpan_dev,
max_csma_backoffs); max_csma_backoffs);
trace_802154_rdev_return_int(&rdev->wpan_phy, ret);
return ret;
} }
static inline int static inline int
rdev_set_max_frame_retries(struct cfg802154_registered_device *rdev, rdev_set_max_frame_retries(struct cfg802154_registered_device *rdev,
struct wpan_dev *wpan_dev, s8 max_frame_retries) struct wpan_dev *wpan_dev, s8 max_frame_retries)
{ {
return rdev->ops->set_max_frame_retries(&rdev->wpan_phy, wpan_dev, int ret;
trace_802154_rdev_set_max_frame_retries(&rdev->wpan_phy, wpan_dev,
max_frame_retries);
ret = rdev->ops->set_max_frame_retries(&rdev->wpan_phy, wpan_dev,
max_frame_retries); max_frame_retries);
trace_802154_rdev_return_int(&rdev->wpan_phy, ret);
return ret;
} }
static inline int static inline int
rdev_set_lbt_mode(struct cfg802154_registered_device *rdev, rdev_set_lbt_mode(struct cfg802154_registered_device *rdev,
struct wpan_dev *wpan_dev, bool mode) struct wpan_dev *wpan_dev, bool mode)
{ {
return rdev->ops->set_lbt_mode(&rdev->wpan_phy, wpan_dev, mode); int ret;
trace_802154_rdev_set_lbt_mode(&rdev->wpan_phy, wpan_dev, mode);
ret = rdev->ops->set_lbt_mode(&rdev->wpan_phy, wpan_dev, mode);
trace_802154_rdev_return_int(&rdev->wpan_phy, ret);
return ret;
} }
#endif /* __CFG802154_RDEV_OPS */ #endif /* __CFG802154_RDEV_OPS */
#include <linux/module.h>
#ifndef __CHECKER__
#define CREATE_TRACE_POINTS
#include "trace.h"
#endif
/* Based on net/wireless/tracing.h */
#undef TRACE_SYSTEM
#define TRACE_SYSTEM cfg802154
#if !defined(__RDEV_CFG802154_OPS_TRACE) || defined(TRACE_HEADER_MULTI_READ)
#define __RDEV_CFG802154_OPS_TRACE
#include <linux/tracepoint.h>
#include <net/cfg802154.h>
#define MAXNAME 32
#define WPAN_PHY_ENTRY __array(char, wpan_phy_name, MAXNAME)
#define WPAN_PHY_ASSIGN strlcpy(__entry->wpan_phy_name, \
wpan_phy_name(wpan_phy), \
MAXNAME)
#define WPAN_PHY_PR_FMT "%s"
#define WPAN_PHY_PR_ARG __entry->wpan_phy_name
#define WPAN_DEV_ENTRY __field(u32, identifier)
#define WPAN_DEV_ASSIGN (__entry->identifier) = (!IS_ERR_OR_NULL(wpan_dev) \
? wpan_dev->identifier : 0)
#define WPAN_DEV_PR_FMT "wpan_dev(%u)"
#define WPAN_DEV_PR_ARG (__entry->identifier)
#define WPAN_CCA_ENTRY __field(enum nl802154_cca_modes, cca_mode) \
__field(enum nl802154_cca_opts, cca_opt)
#define WPAN_CCA_ASSIGN \
do { \
(__entry->cca_mode) = cca->mode; \
(__entry->cca_opt) = cca->opt; \
} while (0)
#define WPAN_CCA_PR_FMT "cca_mode: %d, cca_opt: %d"
#define WPAN_CCA_PR_ARG __entry->cca_mode, __entry->cca_opt
#define BOOL_TO_STR(bo) (bo) ? "true" : "false"
/*************************************************************
* rdev->ops traces *
*************************************************************/
TRACE_EVENT(802154_rdev_add_virtual_intf,
TP_PROTO(struct wpan_phy *wpan_phy, char *name,
enum nl802154_iftype type, __le64 extended_addr),
TP_ARGS(wpan_phy, name, type, extended_addr),
TP_STRUCT__entry(
WPAN_PHY_ENTRY
__string(vir_intf_name, name ? name : "<noname>")
__field(enum nl802154_iftype, type)
__field(__le64, extended_addr)
),
TP_fast_assign(
WPAN_PHY_ASSIGN;
__assign_str(vir_intf_name, name ? name : "<noname>");
__entry->type = type;
__entry->extended_addr = extended_addr;
),
TP_printk(WPAN_PHY_PR_FMT ", virtual intf name: %s, type: %d, ea %llx",
WPAN_PHY_PR_ARG, __get_str(vir_intf_name), __entry->type,
__le64_to_cpu(__entry->extended_addr))
);
TRACE_EVENT(802154_rdev_del_virtual_intf,
TP_PROTO(struct wpan_phy *wpan_phy, struct wpan_dev *wpan_dev),
TP_ARGS(wpan_phy, wpan_dev),
TP_STRUCT__entry(
WPAN_PHY_ENTRY
WPAN_DEV_ENTRY
),
TP_fast_assign(
WPAN_PHY_ASSIGN;
WPAN_DEV_ASSIGN;
),
TP_printk(WPAN_PHY_PR_FMT ", " WPAN_DEV_PR_FMT, WPAN_PHY_PR_ARG,
WPAN_DEV_PR_ARG)
);
TRACE_EVENT(802154_rdev_set_channel,
TP_PROTO(struct wpan_phy *wpan_phy, u8 page, u8 channel),
TP_ARGS(wpan_phy, page, channel),
TP_STRUCT__entry(
WPAN_PHY_ENTRY
__field(u8, page)
__field(u8, channel)
),
TP_fast_assign(
WPAN_PHY_ASSIGN;
__entry->page = page;
__entry->channel = channel;
),
TP_printk(WPAN_PHY_PR_FMT ", page: %d, channel: %d", WPAN_PHY_PR_ARG,
__entry->page, __entry->channel)
);
TRACE_EVENT(802154_rdev_set_cca_mode,
TP_PROTO(struct wpan_phy *wpan_phy, const struct wpan_phy_cca *cca),
TP_ARGS(wpan_phy, cca),
TP_STRUCT__entry(
WPAN_PHY_ENTRY
WPAN_CCA_ENTRY
),
TP_fast_assign(
WPAN_PHY_ASSIGN;
WPAN_CCA_ASSIGN;
),
TP_printk(WPAN_PHY_PR_FMT ", " WPAN_CCA_PR_FMT, WPAN_PHY_PR_ARG,
WPAN_CCA_PR_ARG)
);
DECLARE_EVENT_CLASS(802154_le16_template,
TP_PROTO(struct wpan_phy *wpan_phy, struct wpan_dev *wpan_dev,
__le16 le16arg),
TP_ARGS(wpan_phy, wpan_dev, le16arg),
TP_STRUCT__entry(
WPAN_PHY_ENTRY
WPAN_DEV_ENTRY
__field(__le16, le16arg)
),
TP_fast_assign(
WPAN_PHY_ASSIGN;
WPAN_DEV_ASSIGN;
__entry->le16arg = le16arg;
),
TP_printk(WPAN_PHY_PR_FMT ", " WPAN_DEV_PR_FMT ", pan id: 0x%04x",
WPAN_PHY_PR_ARG, WPAN_DEV_PR_ARG,
__le16_to_cpu(__entry->le16arg))
);
DEFINE_EVENT(802154_le16_template, 802154_rdev_set_pan_id,
TP_PROTO(struct wpan_phy *wpan_phy, struct wpan_dev *wpan_dev,
__le16 le16arg),
TP_ARGS(wpan_phy, wpan_dev, le16arg)
);
DEFINE_EVENT_PRINT(802154_le16_template, 802154_rdev_set_short_addr,
TP_PROTO(struct wpan_phy *wpan_phy, struct wpan_dev *wpan_dev,
__le16 le16arg),
TP_ARGS(wpan_phy, wpan_dev, le16arg),
TP_printk(WPAN_PHY_PR_FMT ", " WPAN_DEV_PR_FMT ", sa: 0x%04x",
WPAN_PHY_PR_ARG, WPAN_DEV_PR_ARG,
__le16_to_cpu(__entry->le16arg))
);
TRACE_EVENT(802154_rdev_set_backoff_exponent,
TP_PROTO(struct wpan_phy *wpan_phy, struct wpan_dev *wpan_dev,
u8 min_be, u8 max_be),
TP_ARGS(wpan_phy, wpan_dev, min_be, max_be),
TP_STRUCT__entry(
WPAN_PHY_ENTRY
WPAN_DEV_ENTRY
__field(u8, min_be)
__field(u8, max_be)
),
TP_fast_assign(
WPAN_PHY_ASSIGN;
WPAN_DEV_ASSIGN;
__entry->min_be = min_be;
__entry->max_be = max_be;
),
TP_printk(WPAN_PHY_PR_FMT ", " WPAN_DEV_PR_FMT
", min be: %d, max_be: %d", WPAN_PHY_PR_ARG,
WPAN_DEV_PR_ARG, __entry->min_be, __entry->max_be)
);
TRACE_EVENT(802154_rdev_set_csma_backoffs,
TP_PROTO(struct wpan_phy *wpan_phy, struct wpan_dev *wpan_dev,
u8 max_csma_backoffs),
TP_ARGS(wpan_phy, wpan_dev, max_csma_backoffs),
TP_STRUCT__entry(
WPAN_PHY_ENTRY
WPAN_DEV_ENTRY
__field(u8, max_csma_backoffs)
),
TP_fast_assign(
WPAN_PHY_ASSIGN;
WPAN_DEV_ASSIGN;
__entry->max_csma_backoffs = max_csma_backoffs;
),
TP_printk(WPAN_PHY_PR_FMT ", " WPAN_DEV_PR_FMT
", max csma backoffs: %d", WPAN_PHY_PR_ARG,
WPAN_DEV_PR_ARG, __entry->max_csma_backoffs)
);
TRACE_EVENT(802154_rdev_set_max_frame_retries,
TP_PROTO(struct wpan_phy *wpan_phy, struct wpan_dev *wpan_dev,
s8 max_frame_retries),
TP_ARGS(wpan_phy, wpan_dev, max_frame_retries),
TP_STRUCT__entry(
WPAN_PHY_ENTRY
WPAN_DEV_ENTRY
__field(s8, max_frame_retries)
),
TP_fast_assign(
WPAN_PHY_ASSIGN;
WPAN_DEV_ASSIGN;
__entry->max_frame_retries = max_frame_retries;
),
TP_printk(WPAN_PHY_PR_FMT ", " WPAN_DEV_PR_FMT
", max frame retries: %d", WPAN_PHY_PR_ARG,
WPAN_DEV_PR_ARG, __entry->max_frame_retries)
);
TRACE_EVENT(802154_rdev_set_lbt_mode,
TP_PROTO(struct wpan_phy *wpan_phy, struct wpan_dev *wpan_dev,
bool mode),
TP_ARGS(wpan_phy, wpan_dev, mode),
TP_STRUCT__entry(
WPAN_PHY_ENTRY
WPAN_DEV_ENTRY
__field(bool, mode)
),
TP_fast_assign(
WPAN_PHY_ASSIGN;
WPAN_DEV_ASSIGN;
__entry->mode = mode;
),
TP_printk(WPAN_PHY_PR_FMT ", " WPAN_DEV_PR_FMT
", lbt mode: %s", WPAN_PHY_PR_ARG,
WPAN_DEV_PR_ARG, BOOL_TO_STR(__entry->mode))
);
TRACE_EVENT(802154_rdev_return_int,
TP_PROTO(struct wpan_phy *wpan_phy, int ret),
TP_ARGS(wpan_phy, ret),
TP_STRUCT__entry(
WPAN_PHY_ENTRY
__field(int, ret)
),
TP_fast_assign(
WPAN_PHY_ASSIGN;
__entry->ret = ret;
),
TP_printk(WPAN_PHY_PR_FMT ", returned: %d", WPAN_PHY_PR_ARG,
__entry->ret)
);
#endif /* !__RDEV_CFG802154_OPS_TRACE || TRACE_HEADER_MULTI_READ */
#undef TRACE_INCLUDE_PATH
#define TRACE_INCLUDE_PATH .
#undef TRACE_INCLUDE_FILE
#define TRACE_INCLUDE_FILE trace
#include <trace/define_trace.h>
...@@ -224,14 +224,16 @@ int inet_sk_diag_fill(struct sock *sk, struct inet_connection_sock *icsk, ...@@ -224,14 +224,16 @@ int inet_sk_diag_fill(struct sock *sk, struct inet_connection_sock *icsk,
handler->idiag_get_info(sk, r, info); handler->idiag_get_info(sk, r, info);
if (sk->sk_state < TCP_TIME_WAIT) { if (sk->sk_state < TCP_TIME_WAIT) {
int err = 0; union tcp_cc_info info;
size_t sz = 0;
int attr;
rcu_read_lock(); rcu_read_lock();
ca_ops = READ_ONCE(icsk->icsk_ca_ops); ca_ops = READ_ONCE(icsk->icsk_ca_ops);
if (ca_ops && ca_ops->get_info) if (ca_ops && ca_ops->get_info)
err = ca_ops->get_info(sk, ext, skb); sz = ca_ops->get_info(sk, ext, &attr, &info);
rcu_read_unlock(); rcu_read_unlock();
if (err < 0) if (sz && nla_put(skb, attr, sz, &info) < 0)
goto errout; goto errout;
} }
......
...@@ -252,6 +252,7 @@ ...@@ -252,6 +252,7 @@
#include <linux/types.h> #include <linux/types.h>
#include <linux/fcntl.h> #include <linux/fcntl.h>
#include <linux/poll.h> #include <linux/poll.h>
#include <linux/inet_diag.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/fs.h> #include <linux/fs.h>
#include <linux/skbuff.h> #include <linux/skbuff.h>
...@@ -2592,7 +2593,7 @@ EXPORT_SYMBOL(compat_tcp_setsockopt); ...@@ -2592,7 +2593,7 @@ EXPORT_SYMBOL(compat_tcp_setsockopt);
#endif #endif
/* Return information about state of tcp endpoint in API format. */ /* Return information about state of tcp endpoint in API format. */
void tcp_get_info(const struct sock *sk, struct tcp_info *info) void tcp_get_info(struct sock *sk, struct tcp_info *info)
{ {
const struct tcp_sock *tp = tcp_sk(sk); const struct tcp_sock *tp = tcp_sk(sk);
const struct inet_connection_sock *icsk = inet_csk(sk); 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,6 +2664,11 @@ void tcp_get_info(const struct sock *sk, struct tcp_info *info)
rate = READ_ONCE(sk->sk_max_pacing_rate); rate = READ_ONCE(sk->sk_max_pacing_rate);
info->tcpi_max_pacing_rate = rate != ~0U ? rate : ~0ULL; info->tcpi_max_pacing_rate = rate != ~0U ? rate : ~0ULL;
spin_lock_bh(&sk->sk_lock.slock);
info->tcpi_bytes_acked = tp->bytes_acked;
info->tcpi_bytes_received = tp->bytes_received;
spin_unlock_bh(&sk->sk_lock.slock);
} }
EXPORT_SYMBOL_GPL(tcp_get_info); EXPORT_SYMBOL_GPL(tcp_get_info);
...@@ -2734,6 +2740,26 @@ static int do_tcp_getsockopt(struct sock *sk, int level, ...@@ -2734,6 +2740,26 @@ static int do_tcp_getsockopt(struct sock *sk, int level,
return -EFAULT; return -EFAULT;
return 0; return 0;
} }
case TCP_CC_INFO: {
const struct tcp_congestion_ops *ca_ops;
union tcp_cc_info info;
size_t sz = 0;
int attr;
if (get_user(len, optlen))
return -EFAULT;
ca_ops = icsk->icsk_ca_ops;
if (ca_ops && ca_ops->get_info)
sz = ca_ops->get_info(sk, ~0U, &attr, &info);
len = min_t(unsigned int, len, sz);
if (put_user(len, optlen))
return -EFAULT;
if (copy_to_user(optval, &info, len))
return -EFAULT;
return 0;
}
case TCP_QUICKACK: case TCP_QUICKACK:
val = !icsk->icsk_ack.pingpong; val = !icsk->icsk_ack.pingpong;
break; break;
......
...@@ -277,7 +277,8 @@ static void dctcp_cwnd_event(struct sock *sk, enum tcp_ca_event ev) ...@@ -277,7 +277,8 @@ static void dctcp_cwnd_event(struct sock *sk, enum tcp_ca_event ev)
} }
} }
static int dctcp_get_info(struct sock *sk, u32 ext, struct sk_buff *skb) static size_t dctcp_get_info(struct sock *sk, u32 ext, int *attr,
union tcp_cc_info *info)
{ {
const struct dctcp *ca = inet_csk_ca(sk); const struct dctcp *ca = inet_csk_ca(sk);
...@@ -286,18 +287,17 @@ static int dctcp_get_info(struct sock *sk, u32 ext, struct sk_buff *skb) ...@@ -286,18 +287,17 @@ static int dctcp_get_info(struct sock *sk, u32 ext, struct sk_buff *skb)
*/ */
if (ext & (1 << (INET_DIAG_DCTCPINFO - 1)) || if (ext & (1 << (INET_DIAG_DCTCPINFO - 1)) ||
ext & (1 << (INET_DIAG_VEGASINFO - 1))) { ext & (1 << (INET_DIAG_VEGASINFO - 1))) {
struct tcp_dctcp_info info; memset(info, 0, sizeof(struct tcp_dctcp_info));
memset(&info, 0, sizeof(info));
if (inet_csk(sk)->icsk_ca_ops != &dctcp_reno) { if (inet_csk(sk)->icsk_ca_ops != &dctcp_reno) {
info.dctcp_enabled = 1; info->dctcp.dctcp_enabled = 1;
info.dctcp_ce_state = (u16) ca->ce_state; info->dctcp.dctcp_ce_state = (u16) ca->ce_state;
info.dctcp_alpha = ca->dctcp_alpha; info->dctcp.dctcp_alpha = ca->dctcp_alpha;
info.dctcp_ab_ecn = ca->acked_bytes_ecn; info->dctcp.dctcp_ab_ecn = ca->acked_bytes_ecn;
info.dctcp_ab_tot = ca->acked_bytes_total; info->dctcp.dctcp_ab_tot = ca->acked_bytes_total;
} }
return nla_put(skb, INET_DIAG_DCTCPINFO, sizeof(info), &info); *attr = INET_DIAG_DCTCPINFO;
return sizeof(*info);
} }
return 0; return 0;
} }
......
...@@ -206,6 +206,7 @@ static bool tcp_fastopen_create_child(struct sock *sk, ...@@ -206,6 +206,7 @@ static bool tcp_fastopen_create_child(struct sock *sk,
skb_set_owner_r(skb2, child); skb_set_owner_r(skb2, child);
__skb_queue_tail(&child->sk_receive_queue, skb2); __skb_queue_tail(&child->sk_receive_queue, skb2);
tp->syn_data_acked = 1; tp->syn_data_acked = 1;
tp->bytes_received = end_seq - TCP_SKB_CB(skb)->seq - 1;
} else { } else {
end_seq = TCP_SKB_CB(skb)->seq + 1; end_seq = TCP_SKB_CB(skb)->seq + 1;
} }
......
...@@ -300,24 +300,25 @@ static u32 tcp_illinois_ssthresh(struct sock *sk) ...@@ -300,24 +300,25 @@ static u32 tcp_illinois_ssthresh(struct sock *sk)
} }
/* Extract info for Tcp socket info provided via netlink. */ /* Extract info for Tcp socket info provided via netlink. */
static int tcp_illinois_info(struct sock *sk, u32 ext, struct sk_buff *skb) static size_t tcp_illinois_info(struct sock *sk, u32 ext, int *attr,
union tcp_cc_info *info)
{ {
const struct illinois *ca = inet_csk_ca(sk); const struct illinois *ca = inet_csk_ca(sk);
if (ext & (1 << (INET_DIAG_VEGASINFO - 1))) { if (ext & (1 << (INET_DIAG_VEGASINFO - 1))) {
struct tcpvegas_info info = { info->vegas.tcpv_enabled = 1;
.tcpv_enabled = 1, info->vegas.tcpv_rttcnt = ca->cnt_rtt;
.tcpv_rttcnt = ca->cnt_rtt, info->vegas.tcpv_minrtt = ca->base_rtt;
.tcpv_minrtt = ca->base_rtt, info->vegas.tcpv_rtt = 0;
};
if (info.tcpv_rttcnt > 0) { if (info->vegas.tcpv_rttcnt > 0) {
u64 t = ca->sum_rtt; u64 t = ca->sum_rtt;
do_div(t, info.tcpv_rttcnt); do_div(t, info->vegas.tcpv_rttcnt);
info.tcpv_rtt = t; info->vegas.tcpv_rtt = t;
} }
return nla_put(skb, INET_DIAG_VEGASINFO, sizeof(info), &info); *attr = INET_DIAG_VEGASINFO;
return sizeof(struct tcpvegas_info);
} }
return 0; return 0;
} }
......
...@@ -1820,14 +1820,12 @@ tcp_sacktag_write_queue(struct sock *sk, const struct sk_buff *ack_skb, ...@@ -1820,14 +1820,12 @@ tcp_sacktag_write_queue(struct sock *sk, const struct sk_buff *ack_skb,
for (j = 0; j < used_sacks; j++) for (j = 0; j < used_sacks; j++)
tp->recv_sack_cache[i++] = sp[j]; tp->recv_sack_cache[i++] = sp[j];
tcp_mark_lost_retrans(sk);
tcp_verify_left_out(tp);
if ((state.reord < tp->fackets_out) && if ((state.reord < tp->fackets_out) &&
((inet_csk(sk)->icsk_ca_state != TCP_CA_Loss) || tp->undo_marker)) ((inet_csk(sk)->icsk_ca_state != TCP_CA_Loss) || tp->undo_marker))
tcp_update_reordering(sk, tp->fackets_out - state.reord, 0); tcp_update_reordering(sk, tp->fackets_out - state.reord, 0);
tcp_mark_lost_retrans(sk);
tcp_verify_left_out(tp);
out: out:
#if FASTRETRANS_DEBUG > 0 #if FASTRETRANS_DEBUG > 0
...@@ -3280,6 +3278,24 @@ static inline bool tcp_may_update_window(const struct tcp_sock *tp, ...@@ -3280,6 +3278,24 @@ static inline bool tcp_may_update_window(const struct tcp_sock *tp,
(ack_seq == tp->snd_wl1 && nwin > tp->snd_wnd); (ack_seq == tp->snd_wl1 && nwin > tp->snd_wnd);
} }
/* If we update tp->snd_una, also update tp->bytes_acked */
static void tcp_snd_una_update(struct tcp_sock *tp, u32 ack)
{
u32 delta = ack - tp->snd_una;
tp->bytes_acked += delta;
tp->snd_una = ack;
}
/* If we update tp->rcv_nxt, also update tp->bytes_received */
static void tcp_rcv_nxt_update(struct tcp_sock *tp, u32 seq)
{
u32 delta = seq - tp->rcv_nxt;
tp->bytes_received += delta;
tp->rcv_nxt = seq;
}
/* Update our send window. /* Update our send window.
* *
* Window update algorithm, described in RFC793/RFC1122 (used in linux-2.2 * 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,7 +3331,7 @@ static int tcp_ack_update_window(struct sock *sk, const struct sk_buff *skb, u32
} }
} }
tp->snd_una = ack; tcp_snd_una_update(tp, ack);
return flag; return flag;
} }
...@@ -3497,7 +3513,7 @@ static int tcp_ack(struct sock *sk, const struct sk_buff *skb, int flag) ...@@ -3497,7 +3513,7 @@ static int tcp_ack(struct sock *sk, const struct sk_buff *skb, int flag)
* Note, we use the fact that SND.UNA>=SND.WL2. * Note, we use the fact that SND.UNA>=SND.WL2.
*/ */
tcp_update_wl(tp, ack_seq); tcp_update_wl(tp, ack_seq);
tp->snd_una = ack; tcp_snd_una_update(tp, ack);
flag |= FLAG_WIN_UPDATE; flag |= FLAG_WIN_UPDATE;
tcp_in_ack_event(sk, CA_ACK_WIN_UPDATE); tcp_in_ack_event(sk, CA_ACK_WIN_UPDATE);
...@@ -4236,7 +4252,7 @@ static void tcp_ofo_queue(struct sock *sk) ...@@ -4236,7 +4252,7 @@ static void tcp_ofo_queue(struct sock *sk)
tail = skb_peek_tail(&sk->sk_receive_queue); tail = skb_peek_tail(&sk->sk_receive_queue);
eaten = tail && tcp_try_coalesce(sk, tail, skb, &fragstolen); eaten = tail && tcp_try_coalesce(sk, tail, skb, &fragstolen);
tp->rcv_nxt = TCP_SKB_CB(skb)->end_seq; tcp_rcv_nxt_update(tp, TCP_SKB_CB(skb)->end_seq);
if (!eaten) if (!eaten)
__skb_queue_tail(&sk->sk_receive_queue, skb); __skb_queue_tail(&sk->sk_receive_queue, skb);
if (TCP_SKB_CB(skb)->tcp_flags & TCPHDR_FIN) 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,7 +4420,7 @@ static int __must_check tcp_queue_rcv(struct sock *sk, struct sk_buff *skb, int
__skb_pull(skb, hdrlen); __skb_pull(skb, hdrlen);
eaten = (tail && eaten = (tail &&
tcp_try_coalesce(sk, tail, skb, fragstolen)) ? 1 : 0; tcp_try_coalesce(sk, tail, skb, fragstolen)) ? 1 : 0;
tcp_sk(sk)->rcv_nxt = TCP_SKB_CB(skb)->end_seq; tcp_rcv_nxt_update(tcp_sk(sk), TCP_SKB_CB(skb)->end_seq);
if (!eaten) { if (!eaten) {
__skb_queue_tail(&sk->sk_receive_queue, skb); __skb_queue_tail(&sk->sk_receive_queue, skb);
skb_set_owner_r(skb, sk); skb_set_owner_r(skb, sk);
...@@ -4497,7 +4513,7 @@ static void tcp_data_queue(struct sock *sk, struct sk_buff *skb) ...@@ -4497,7 +4513,7 @@ static void tcp_data_queue(struct sock *sk, struct sk_buff *skb)
eaten = tcp_queue_rcv(sk, skb, 0, &fragstolen); eaten = tcp_queue_rcv(sk, skb, 0, &fragstolen);
} }
tp->rcv_nxt = TCP_SKB_CB(skb)->end_seq; tcp_rcv_nxt_update(tp, TCP_SKB_CB(skb)->end_seq);
if (skb->len) if (skb->len)
tcp_event_data_recv(sk, skb); tcp_event_data_recv(sk, skb);
if (TCP_SKB_CB(skb)->tcp_flags & TCPHDR_FIN) 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,7 +5261,7 @@ void tcp_rcv_established(struct sock *sk, struct sk_buff *skb,
tcp_rcv_rtt_measure_ts(sk, skb); tcp_rcv_rtt_measure_ts(sk, skb);
__skb_pull(skb, tcp_header_len); __skb_pull(skb, tcp_header_len);
tp->rcv_nxt = TCP_SKB_CB(skb)->end_seq; tcp_rcv_nxt_update(tp, TCP_SKB_CB(skb)->end_seq);
NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_TCPHPHITSTOUSER); NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_TCPHPHITSTOUSER);
eaten = 1; eaten = 1;
} }
......
...@@ -286,18 +286,19 @@ static void tcp_vegas_cong_avoid(struct sock *sk, u32 ack, u32 acked) ...@@ -286,18 +286,19 @@ static void tcp_vegas_cong_avoid(struct sock *sk, u32 ack, u32 acked)
} }
/* Extract info for Tcp socket info provided via netlink. */ /* Extract info for Tcp socket info provided via netlink. */
int tcp_vegas_get_info(struct sock *sk, u32 ext, struct sk_buff *skb) size_t tcp_vegas_get_info(struct sock *sk, u32 ext, int *attr,
union tcp_cc_info *info)
{ {
const struct vegas *ca = inet_csk_ca(sk); const struct vegas *ca = inet_csk_ca(sk);
if (ext & (1 << (INET_DIAG_VEGASINFO - 1))) { if (ext & (1 << (INET_DIAG_VEGASINFO - 1))) {
struct tcpvegas_info info = { info->vegas.tcpv_enabled = ca->doing_vegas_now,
.tcpv_enabled = ca->doing_vegas_now, info->vegas.tcpv_rttcnt = ca->cntRTT,
.tcpv_rttcnt = ca->cntRTT, info->vegas.tcpv_rtt = ca->baseRTT,
.tcpv_rtt = ca->baseRTT, info->vegas.tcpv_minrtt = ca->minRTT,
.tcpv_minrtt = ca->minRTT,
}; *attr = INET_DIAG_VEGASINFO;
return sizeof(struct tcpvegas_info);
return nla_put(skb, INET_DIAG_VEGASINFO, sizeof(info), &info);
} }
return 0; return 0;
} }
......
...@@ -19,6 +19,7 @@ void tcp_vegas_init(struct sock *sk); ...@@ -19,6 +19,7 @@ void tcp_vegas_init(struct sock *sk);
void tcp_vegas_state(struct sock *sk, u8 ca_state); void tcp_vegas_state(struct sock *sk, u8 ca_state);
void tcp_vegas_pkts_acked(struct sock *sk, u32 cnt, s32 rtt_us); void tcp_vegas_pkts_acked(struct sock *sk, u32 cnt, s32 rtt_us);
void tcp_vegas_cwnd_event(struct sock *sk, enum tcp_ca_event event); void tcp_vegas_cwnd_event(struct sock *sk, enum tcp_ca_event event);
int tcp_vegas_get_info(struct sock *sk, u32 ext, struct sk_buff *skb); size_t tcp_vegas_get_info(struct sock *sk, u32 ext, int *attr,
union tcp_cc_info *info);
#endif /* __TCP_VEGAS_H */ #endif /* __TCP_VEGAS_H */
...@@ -22,13 +22,14 @@ ...@@ -22,13 +22,14 @@
static struct net_device * static struct net_device *
ieee802154_add_iface_deprecated(struct wpan_phy *wpan_phy, ieee802154_add_iface_deprecated(struct wpan_phy *wpan_phy,
const char *name, int type) const char *name,
unsigned char name_assign_type, int type)
{ {
struct ieee802154_local *local = wpan_phy_priv(wpan_phy); struct ieee802154_local *local = wpan_phy_priv(wpan_phy);
struct net_device *dev; struct net_device *dev;
rtnl_lock(); rtnl_lock();
dev = ieee802154_if_add(local, name, type, dev = ieee802154_if_add(local, name, name_assign_type, type,
cpu_to_le64(0x0000000000000000ULL)); cpu_to_le64(0x0000000000000000ULL));
rtnl_unlock(); rtnl_unlock();
...@@ -45,12 +46,14 @@ static void ieee802154_del_iface_deprecated(struct wpan_phy *wpan_phy, ...@@ -45,12 +46,14 @@ static void ieee802154_del_iface_deprecated(struct wpan_phy *wpan_phy,
static int static int
ieee802154_add_iface(struct wpan_phy *phy, const char *name, ieee802154_add_iface(struct wpan_phy *phy, const char *name,
unsigned char name_assign_type,
enum nl802154_iftype type, __le64 extended_addr) enum nl802154_iftype type, __le64 extended_addr)
{ {
struct ieee802154_local *local = wpan_phy_priv(phy); struct ieee802154_local *local = wpan_phy_priv(phy);
struct net_device *err; struct net_device *err;
err = ieee802154_if_add(local, name, type, extended_addr); err = ieee802154_if_add(local, name, name_assign_type, type,
extended_addr);
return PTR_ERR_OR_ZERO(err); return PTR_ERR_OR_ZERO(err);
} }
......
...@@ -182,7 +182,8 @@ void ieee802154_iface_exit(void); ...@@ -182,7 +182,8 @@ void ieee802154_iface_exit(void);
void ieee802154_if_remove(struct ieee802154_sub_if_data *sdata); void ieee802154_if_remove(struct ieee802154_sub_if_data *sdata);
struct net_device * struct net_device *
ieee802154_if_add(struct ieee802154_local *local, const char *name, ieee802154_if_add(struct ieee802154_local *local, const char *name,
enum nl802154_iftype type, __le64 extended_addr); unsigned char name_assign_type, enum nl802154_iftype type,
__le64 extended_addr);
void ieee802154_remove_interfaces(struct ieee802154_local *local); void ieee802154_remove_interfaces(struct ieee802154_local *local);
#endif /* __IEEE802154_I_H */ #endif /* __IEEE802154_I_H */
...@@ -522,7 +522,8 @@ ieee802154_setup_sdata(struct ieee802154_sub_if_data *sdata, ...@@ -522,7 +522,8 @@ ieee802154_setup_sdata(struct ieee802154_sub_if_data *sdata,
struct net_device * struct net_device *
ieee802154_if_add(struct ieee802154_local *local, const char *name, ieee802154_if_add(struct ieee802154_local *local, const char *name,
enum nl802154_iftype type, __le64 extended_addr) unsigned char name_assign_type, enum nl802154_iftype type,
__le64 extended_addr)
{ {
struct net_device *ndev = NULL; struct net_device *ndev = NULL;
struct ieee802154_sub_if_data *sdata = NULL; struct ieee802154_sub_if_data *sdata = NULL;
...@@ -531,7 +532,7 @@ ieee802154_if_add(struct ieee802154_local *local, const char *name, ...@@ -531,7 +532,7 @@ ieee802154_if_add(struct ieee802154_local *local, const char *name,
ASSERT_RTNL(); ASSERT_RTNL();
ndev = alloc_netdev(sizeof(*sdata) + local->hw.vif_data_size, name, ndev = alloc_netdev(sizeof(*sdata) + local->hw.vif_data_size, name,
NET_NAME_UNKNOWN, ieee802154_if_setup); name_assign_type, ieee802154_if_setup);
if (!ndev) if (!ndev)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
......
...@@ -161,7 +161,8 @@ int ieee802154_register_hw(struct ieee802154_hw *hw) ...@@ -161,7 +161,8 @@ int ieee802154_register_hw(struct ieee802154_hw *hw)
rtnl_lock(); rtnl_lock();
dev = ieee802154_if_add(local, "wpan%d", NL802154_IFTYPE_NODE, dev = ieee802154_if_add(local, "wpan%d", NET_NAME_ENUM,
NL802154_IFTYPE_NODE,
cpu_to_le64(0x0000000000000000ULL)); cpu_to_le64(0x0000000000000000ULL));
if (IS_ERR(dev)) { if (IS_ERR(dev)) {
rtnl_unlock(); rtnl_unlock();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment