All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH bluetooth-next 0/4] ieee802154: atusb: drivers updates for v0.3 firmware
@ 2016-12-05 13:47 Stefan Schmidt
  2016-12-05 13:47 ` [PATCH bluetooth-next 1/4] ieee802154: atusb: sync header file from firmware for new features Stefan Schmidt
                   ` (4 more replies)
  0 siblings, 5 replies; 9+ messages in thread
From: Stefan Schmidt @ 2016-12-05 13:47 UTC (permalink / raw)
  To: linux-wpan; +Cc: Alexander Aring, Stefan Schmidt

Hello.

With the version 0.3 for the ATUSB firmware finally out of the door here are the
corresponding kernel driver patches to make use of the new functionality.

While the first to patches are just preparation the last two are useful enhancements. An permanent
EUI64 address can now be hold in the EEPROM of the ATUSB dongle to survive reboots and allowing a
unique identification and no need to mess around with generated addresses after each device probe.

All new ATUSB dongles will have a address set in EEPROM already, for devices that are out in the
wild already you would have to ask me to assign you an official one if you want it. Feel free to do
so. :)

The last one allows to set the maximal fram reties values now that we support the needed states
inside the firmware. This finishes the hardware assisted ACK handling on the TX site. RX side was
working for a long time already.

Stefan Schmidt (4):
  ieee802154: atusb: sync header file from firmware for new features
  ieee802154: atusb: store firmware version after retrieval for later
    use
  ieee802154: atusb: try to read permanent extended address from device
  ieee802154: atusb: implement .set_frame_retries ops callback

 drivers/net/ieee802154/atusb.c | 79 ++++++++++++++++++++++++++++++++++++++----
 drivers/net/ieee802154/atusb.h | 11 ++++--
 2 files changed, 80 insertions(+), 10 deletions(-)

regards
Stefan Schmidt

-- 
2.5.5


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH bluetooth-next 1/4] ieee802154: atusb: sync header file from firmware for new features
  2016-12-05 13:47 [PATCH bluetooth-next 0/4] ieee802154: atusb: drivers updates for v0.3 firmware Stefan Schmidt
@ 2016-12-05 13:47 ` Stefan Schmidt
  2016-12-05 13:47 ` [PATCH bluetooth-next 2/4] ieee802154: atusb: store firmware version after retrieval for later use Stefan Schmidt
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 9+ messages in thread
From: Stefan Schmidt @ 2016-12-05 13:47 UTC (permalink / raw)
  To: linux-wpan; +Cc: Alexander Aring, Stefan Schmidt

This file is shared between the atusb firmware and the kernel driver. In this
update it brings the new interfaces from version 0.3 of the firmware.

Signed-off-by: Stefan Schmidt <stefan@osg.samsung.com>
---
 drivers/net/ieee802154/atusb.h | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ieee802154/atusb.h b/drivers/net/ieee802154/atusb.h
index 0690edc..b22bbaa 100644
--- a/drivers/net/ieee802154/atusb.h
+++ b/drivers/net/ieee802154/atusb.h
@@ -13,8 +13,8 @@
  * Firmware: ben-wpan/atusb/fw/include/atusb/atusb.h
  */
 
-#ifndef _ATUSB_H
-#define _ATUSB_H
+#ifndef	_ATUSB_H
+#define	_ATUSB_H
 
 #define ATUSB_VENDOR_ID	0x20b7	/* Qi Hardware*/
 #define ATUSB_PRODUCT_ID 0x1540	/* 802.15.4, device 0 */
@@ -46,9 +46,12 @@ enum atusb_requests {
 	ATUSB_SPI_WRITE2_SYNC,
 	ATUSB_RX_MODE			= 0x40, /* HardMAC group */
 	ATUSB_TX,
+	ATUSB_EUI64_WRITE		= 0x50, /* Parameter in EEPROM grp */
+	ATUSB_EUI64_READ,
 };
 
-/* Direction	bRequest		wValue		wIndex	wLength
+/*
+ * Direction	bRequest		wValue		wIndex	wLength
  *
  * ->host	ATUSB_ID		-		-	3
  * ->host	ATUSB_BUILD		-		-	#bytes
@@ -76,6 +79,8 @@ enum atusb_requests {
  *
  * host->	ATUSB_RX_MODE		on		-	0
  * host->	ATUSB_TX		flags		ack_seq	#bytes
+ * host->	ATUSB_EUI64_WRITE	-		-	#bytes (8)
+ * ->host	ATUSB_EUI64_READ	-		-	#bytes (8)
  */
 
 #define ATUSB_REQ_FROM_DEV	(USB_TYPE_VENDOR | USB_DIR_IN)
-- 
2.5.5


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH bluetooth-next 2/4] ieee802154: atusb: store firmware version after retrieval for later use
  2016-12-05 13:47 [PATCH bluetooth-next 0/4] ieee802154: atusb: drivers updates for v0.3 firmware Stefan Schmidt
  2016-12-05 13:47 ` [PATCH bluetooth-next 1/4] ieee802154: atusb: sync header file from firmware for new features Stefan Schmidt
@ 2016-12-05 13:47 ` Stefan Schmidt
  2016-12-05 13:47 ` [PATCH bluetooth-next 3/4] ieee802154: atusb: try to read permanent extended address from device Stefan Schmidt
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 9+ messages in thread
From: Stefan Schmidt @ 2016-12-05 13:47 UTC (permalink / raw)
  To: linux-wpan; +Cc: Alexander Aring, Stefan Schmidt

The firmware versions will be used to enable selective features based on the
available firmware on the device. Make sure we do not need to fetch it for
every check but store it after the initial retrieval.

Signed-off-by: Stefan Schmidt <stefan@osg.samsung.com>
---
 drivers/net/ieee802154/atusb.c | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ieee802154/atusb.c b/drivers/net/ieee802154/atusb.c
index 322864a..9fdea64 100644
--- a/drivers/net/ieee802154/atusb.c
+++ b/drivers/net/ieee802154/atusb.c
@@ -58,6 +58,11 @@ struct atusb {
 	struct urb *tx_urb;
 	struct sk_buff *tx_skb;
 	uint8_t tx_ack_seq;		/* current TX ACK sequence number */
+
+	/* Firmware variable */
+	unsigned char fw_ver_maj;	/* Firmware major version number */
+	unsigned char fw_ver_min;	/* Firmware minor version number */
+	unsigned char fw_hw_type;	/* Firmware hardware type */
 };
 
 /* ----- USB commands without data ----------------------------------------- */
@@ -594,14 +599,19 @@ static int atusb_get_and_show_revision(struct atusb *atusb)
 	ret = atusb_control_msg(atusb, usb_rcvctrlpipe(usb_dev, 0),
 				ATUSB_ID, ATUSB_REQ_FROM_DEV, 0, 0,
 				buffer, 3, 1000);
-	if (ret >= 0)
+	if (ret >= 0) {
+		atusb->fw_ver_maj = buffer[0];
+		atusb->fw_ver_min = buffer[1];
+		atusb->fw_hw_type = buffer[2];
+
 		dev_info(&usb_dev->dev,
 			 "Firmware: major: %u, minor: %u, hardware type: %u\n",
-			 buffer[0], buffer[1], buffer[2]);
-	if (buffer[0] == 0 && buffer[1] < 2) {
+			 atusb->fw_ver_maj, atusb->fw_ver_min, atusb->fw_hw_type);
+	}
+	if (atusb->fw_ver_maj == 0 && atusb->fw_ver_min < 2) {
 		dev_info(&usb_dev->dev,
-			 "Firmware version (%u.%u) is predates our first public release.",
-			 buffer[0], buffer[1]);
+			 "Firmware version (%u.%u) predates our first public release.",
+			 atusb->fw_ver_maj, atusb->fw_ver_min);
 		dev_info(&usb_dev->dev, "Please update to version 0.2 or newer");
 	}
 
-- 
2.5.5


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH bluetooth-next 3/4] ieee802154: atusb: try to read permanent extended address from device
  2016-12-05 13:47 [PATCH bluetooth-next 0/4] ieee802154: atusb: drivers updates for v0.3 firmware Stefan Schmidt
  2016-12-05 13:47 ` [PATCH bluetooth-next 1/4] ieee802154: atusb: sync header file from firmware for new features Stefan Schmidt
  2016-12-05 13:47 ` [PATCH bluetooth-next 2/4] ieee802154: atusb: store firmware version after retrieval for later use Stefan Schmidt
@ 2016-12-05 13:47 ` Stefan Schmidt
  2016-12-05 13:47 ` [PATCH bluetooth-next 4/4] ieee802154: atusb: implement .set_frame_retries ops callback Stefan Schmidt
  2016-12-08  7:05 ` [PATCH bluetooth-next 0/4] ieee802154: atusb: drivers updates for v0.3 firmware Marcel Holtmann
  4 siblings, 0 replies; 9+ messages in thread
From: Stefan Schmidt @ 2016-12-05 13:47 UTC (permalink / raw)
  To: linux-wpan; +Cc: Alexander Aring, Stefan Schmidt

With version 0.3 the atusb firmware offers an interface to read a permanent
EUI64 address from the devices EEPROM. This patch checks if the firmware is
new enough and tries to read out and use the address. If this does not work
we fall back to the original randomly generated address.

Signed-off-by: Stefan Schmidt <stefan@osg.samsung.com>
---
 drivers/net/ieee802154/atusb.c | 40 +++++++++++++++++++++++++++++++++++++++-
 1 file changed, 39 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ieee802154/atusb.c b/drivers/net/ieee802154/atusb.c
index 9fdea64..3ed34cc 100644
--- a/drivers/net/ieee802154/atusb.c
+++ b/drivers/net/ieee802154/atusb.c
@@ -679,6 +679,43 @@ static int atusb_get_and_show_chip(struct atusb *atusb)
 	return -ENODEV;
 }
 
+static int atusb_set_extended_addr(struct atusb *atusb)
+{
+	struct usb_device *usb_dev = atusb->usb_dev;
+	unsigned char buffer[IEEE802154_EXTENDED_ADDR_LEN];
+	__le64 extended_addr;
+	u64 addr;
+	int ret;
+
+	/* Firmware versions before 0.3 do not support the EUI64_READ command.
+	 * Just use a random address and be done */
+	if (atusb->fw_ver_maj == 0 && atusb->fw_ver_min < 3) {
+		ieee802154_random_extended_addr(&atusb->hw->phy->perm_extended_addr);
+		return 0;
+	}
+
+	/* Firmware is new enough so we fetch the address from EEPROM */
+	ret = atusb_control_msg(atusb, usb_rcvctrlpipe(usb_dev, 0),
+				ATUSB_EUI64_READ, ATUSB_REQ_FROM_DEV, 0, 0,
+				buffer, IEEE802154_EXTENDED_ADDR_LEN, 1000);
+	if (ret < 0)
+		dev_err(&usb_dev->dev, "failed to fetch extended address\n");
+
+	memcpy(&extended_addr, buffer, IEEE802154_EXTENDED_ADDR_LEN);
+	/* Check if read address is not empty and the unicast bit is set correctly */
+	if (!ieee802154_is_valid_extended_unicast_addr(extended_addr)) {
+		dev_info(&usb_dev->dev, "no permanent extended address found, random address set\n");
+		ieee802154_random_extended_addr(&atusb->hw->phy->perm_extended_addr);
+	} else {
+		atusb->hw->phy->perm_extended_addr = extended_addr;
+		addr = swab64((__force u64)atusb->hw->phy->perm_extended_addr);
+		dev_info(&usb_dev->dev, "Read permanent extended address %8phC from device\n",
+			&addr);
+	}
+
+	return ret;
+}
+
 /* ----- Setup ------------------------------------------------------------- */
 
 static int atusb_probe(struct usb_interface *interface,
@@ -738,13 +775,14 @@ static int atusb_probe(struct usb_interface *interface,
 	hw->phy->supported.tx_powers = atusb_powers;
 	hw->phy->supported.tx_powers_size = ARRAY_SIZE(atusb_powers);
 	hw->phy->transmit_power = hw->phy->supported.tx_powers[0];
-	ieee802154_random_extended_addr(&hw->phy->perm_extended_addr);
 	hw->phy->cca_ed_level = hw->phy->supported.cca_ed_levels[7];
 
 	atusb_command(atusb, ATUSB_RF_RESET, 0);
 	atusb_get_and_show_chip(atusb);
 	atusb_get_and_show_revision(atusb);
 	atusb_get_and_show_build(atusb);
+	atusb_set_extended_addr(atusb);
+
 	ret = atusb_get_and_clear_error(atusb);
 	if (ret) {
 		dev_err(&atusb->usb_dev->dev,
-- 
2.5.5


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH bluetooth-next 4/4] ieee802154: atusb: implement .set_frame_retries ops callback
  2016-12-05 13:47 [PATCH bluetooth-next 0/4] ieee802154: atusb: drivers updates for v0.3 firmware Stefan Schmidt
                   ` (2 preceding siblings ...)
  2016-12-05 13:47 ` [PATCH bluetooth-next 3/4] ieee802154: atusb: try to read permanent extended address from device Stefan Schmidt
@ 2016-12-05 13:47 ` Stefan Schmidt
  2016-12-20 11:13   ` Alexander Aring
  2016-12-08  7:05 ` [PATCH bluetooth-next 0/4] ieee802154: atusb: drivers updates for v0.3 firmware Marcel Holtmann
  4 siblings, 1 reply; 9+ messages in thread
From: Stefan Schmidt @ 2016-12-05 13:47 UTC (permalink / raw)
  To: linux-wpan; +Cc: Alexander Aring, Stefan Schmidt

 From firmware version 0.3 onwards we use the TX_ARET mode allowing for automatic
frame retransmissions. To actually make use of this feature we need to implement
the callback for setting the frame retries.

If the firmware version is to old print a warning and return with invalid value.

Signed-off-by: Stefan Schmidt <stefan@osg.samsung.com>
---
 drivers/net/ieee802154/atusb.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ieee802154/atusb.c b/drivers/net/ieee802154/atusb.c
index 3ed34cc..1253f86 100644
--- a/drivers/net/ieee802154/atusb.c
+++ b/drivers/net/ieee802154/atusb.c
@@ -546,6 +546,21 @@ atusb_set_csma_params(struct ieee802154_hw *hw, u8 min_be, u8 max_be, u8 retries
 }
 
 static int
+atusb_set_frame_retries(struct ieee802154_hw *hw, s8 retries)
+{
+	struct atusb *atusb = hw->priv;
+	struct device *dev = &atusb->usb_dev->dev;
+
+	if (atusb->fw_ver_maj == 0 && atusb->fw_ver_min < 3) {
+		dev_info(dev, "Automatic frame retransmission is only available from "
+			"firmware version 0.3. Please update if you want this feature.");
+		return -EINVAL;
+	}
+
+	return atusb_write_subreg(atusb, SR_MAX_FRAME_RETRIES, retries);
+}
+
+static int
 atusb_set_promiscuous_mode(struct ieee802154_hw *hw, const bool on)
 {
 	struct atusb *atusb = hw->priv;
@@ -584,6 +599,7 @@ static const struct ieee802154_ops atusb_ops = {
 	.set_cca_mode		= atusb_set_cca_mode,
 	.set_cca_ed_level	= atusb_set_cca_ed_level,
 	.set_csma_params	= atusb_set_csma_params,
+	.set_frame_retries	= atusb_set_frame_retries,
 	.set_promiscuous_mode	= atusb_set_promiscuous_mode,
 };
 
@@ -754,7 +770,8 @@ static int atusb_probe(struct usb_interface *interface,
 
 	hw->parent = &usb_dev->dev;
 	hw->flags = IEEE802154_HW_TX_OMIT_CKSUM | IEEE802154_HW_AFILT |
-		    IEEE802154_HW_PROMISCUOUS | IEEE802154_HW_CSMA_PARAMS;
+		    IEEE802154_HW_PROMISCUOUS | IEEE802154_HW_CSMA_PARAMS |
+		    IEEE802154_HW_FRAME_RETRIES;
 
 	hw->phy->flags = WPAN_PHY_FLAG_TXPOWER | WPAN_PHY_FLAG_CCA_ED_LEVEL |
 			 WPAN_PHY_FLAG_CCA_MODE;
-- 
2.5.5


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH bluetooth-next 0/4] ieee802154: atusb: drivers updates for v0.3 firmware
  2016-12-05 13:47 [PATCH bluetooth-next 0/4] ieee802154: atusb: drivers updates for v0.3 firmware Stefan Schmidt
                   ` (3 preceding siblings ...)
  2016-12-05 13:47 ` [PATCH bluetooth-next 4/4] ieee802154: atusb: implement .set_frame_retries ops callback Stefan Schmidt
@ 2016-12-08  7:05 ` Marcel Holtmann
  4 siblings, 0 replies; 9+ messages in thread
From: Marcel Holtmann @ 2016-12-08  7:05 UTC (permalink / raw)
  To: Stefan Schmidt; +Cc: linux-wpan, Alexander Aring

Hi Stefan,

> With the version 0.3 for the ATUSB firmware finally out of the door here are the
> corresponding kernel driver patches to make use of the new functionality.
> 
> While the first to patches are just preparation the last two are useful enhancements. An permanent
> EUI64 address can now be hold in the EEPROM of the ATUSB dongle to survive reboots and allowing a
> unique identification and no need to mess around with generated addresses after each device probe.
> 
> All new ATUSB dongles will have a address set in EEPROM already, for devices that are out in the
> wild already you would have to ask me to assign you an official one if you want it. Feel free to do
> so. :)
> 
> The last one allows to set the maximal fram reties values now that we support the needed states
> inside the firmware. This finishes the hardware assisted ACK handling on the TX site. RX side was
> working for a long time already.
> 
> Stefan Schmidt (4):
>  ieee802154: atusb: sync header file from firmware for new features
>  ieee802154: atusb: store firmware version after retrieval for later
>    use
>  ieee802154: atusb: try to read permanent extended address from device
>  ieee802154: atusb: implement .set_frame_retries ops callback
> 
> drivers/net/ieee802154/atusb.c | 79 ++++++++++++++++++++++++++++++++++++++----
> drivers/net/ieee802154/atusb.h | 11 ++++--
> 2 files changed, 80 insertions(+), 10 deletions(-)

all 4 patches have been applied to bluetooth-next tree.

Regards

Marcel


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH bluetooth-next 4/4] ieee802154: atusb: implement .set_frame_retries ops callback
  2016-12-05 13:47 ` [PATCH bluetooth-next 4/4] ieee802154: atusb: implement .set_frame_retries ops callback Stefan Schmidt
@ 2016-12-20 11:13   ` Alexander Aring
  2016-12-20 11:21     ` Alexander Aring
  2017-01-02 15:01     ` Stefan Schmidt
  0 siblings, 2 replies; 9+ messages in thread
From: Alexander Aring @ 2016-12-20 11:13 UTC (permalink / raw)
  To: Stefan Schmidt; +Cc: linux-wpan


Hi,

On 12/05/2016 02:47 PM, Stefan Schmidt wrote:
> From firmware version 0.3 onwards we use the TX_ARET mode allowing for automatic
> frame retransmissions. To actually make use of this feature we need to implement
> the callback for setting the frame retries.
> 
> If the firmware version is to old print a warning and return with invalid value.
> 
> Signed-off-by: Stefan Schmidt <stefan@osg.samsung.com>
> ---
>  drivers/net/ieee802154/atusb.c | 19 ++++++++++++++++++-
>  1 file changed, 18 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ieee802154/atusb.c b/drivers/net/ieee802154/atusb.c
> index 3ed34cc..1253f86 100644
> --- a/drivers/net/ieee802154/atusb.c
> +++ b/drivers/net/ieee802154/atusb.c
> @@ -546,6 +546,21 @@ atusb_set_csma_params(struct ieee802154_hw *hw, u8 min_be, u8 max_be, u8 retries
>  }
>  
>  static int
> +atusb_set_frame_retries(struct ieee802154_hw *hw, s8 retries)
> +{
> +	struct atusb *atusb = hw->priv;
> +	struct device *dev = &atusb->usb_dev->dev;
> +
> +	if (atusb->fw_ver_maj == 0 && atusb->fw_ver_min < 3) {
> +		dev_info(dev, "Automatic frame retransmission is only available from "
> +			"firmware version 0.3. Please update if you want this feature.");
> +		return -EINVAL;
> +	}
> +

I think the user has not change anymore to use atusb driver with new
firmware now.

Because this will set _currently_ when one interface comes first time up.
I say currently here, because we could change tx parameters on other
way... we just need to be sure that no other tx is currently running
anymore... and then change register values for tx parameters.

One argument +1 to use xmit_async, with workqueue inside the driver we
have no change to get knowledge about locking tx in upper-layer..., but
this is another topic. :-)

> +	return atusb_write_subreg(atusb, SR_MAX_FRAME_RETRIES, retries);
> +}
> +
> +static int
>  atusb_set_promiscuous_mode(struct ieee802154_hw *hw, const bool on)
>  {
>  	struct atusb *atusb = hw->priv;
> @@ -584,6 +599,7 @@ static const struct ieee802154_ops atusb_ops = {
>  	.set_cca_mode		= atusb_set_cca_mode,
>  	.set_cca_ed_level	= atusb_set_cca_ed_level,
>  	.set_csma_params	= atusb_set_csma_params,
> +	.set_frame_retries	= atusb_set_frame_retries,
>  	.set_promiscuous_mode	= atusb_set_promiscuous_mode,
>  };
>  
> @@ -754,7 +770,8 @@ static int atusb_probe(struct usb_interface *interface,
>  
>  	hw->parent = &usb_dev->dev;
>  	hw->flags = IEEE802154_HW_TX_OMIT_CKSUM | IEEE802154_HW_AFILT |
> -		    IEEE802154_HW_PROMISCUOUS | IEEE802154_HW_CSMA_PARAMS;
> +		    IEEE802154_HW_PROMISCUOUS | IEEE802154_HW_CSMA_PARAMS |
> +		    IEEE802154_HW_FRAME_RETRIES;
>  

You should set this flag only if it's new firmware... But not using
TX_ARET has also other effects... It's good now that the firmware use
TX_ARET per default.

The current change is that old firmware users can't bring the interface
anymore up, because it fails with -EINVAL and not chance to turn it off. :-)

- Alex

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH bluetooth-next 4/4] ieee802154: atusb: implement .set_frame_retries ops callback
  2016-12-20 11:13   ` Alexander Aring
@ 2016-12-20 11:21     ` Alexander Aring
  2017-01-02 15:01     ` Stefan Schmidt
  1 sibling, 0 replies; 9+ messages in thread
From: Alexander Aring @ 2016-12-20 11:21 UTC (permalink / raw)
  To: Stefan Schmidt; +Cc: linux-wpan

Hi,

On 12/20/2016 12:13 PM, Alexander Aring wrote:
> 
> Hi,
> 
> On 12/05/2016 02:47 PM, Stefan Schmidt wrote:
>> From firmware version 0.3 onwards we use the TX_ARET mode allowing for automatic
>> frame retransmissions. To actually make use of this feature we need to implement
>> the callback for setting the frame retries.
>>
>> If the firmware version is to old print a warning and return with invalid value.
>>
>> Signed-off-by: Stefan Schmidt <stefan@osg.samsung.com>
>> ---
>>  drivers/net/ieee802154/atusb.c | 19 ++++++++++++++++++-
>>  1 file changed, 18 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/net/ieee802154/atusb.c b/drivers/net/ieee802154/atusb.c
>> index 3ed34cc..1253f86 100644
>> --- a/drivers/net/ieee802154/atusb.c
>> +++ b/drivers/net/ieee802154/atusb.c
>> @@ -546,6 +546,21 @@ atusb_set_csma_params(struct ieee802154_hw *hw, u8 min_be, u8 max_be, u8 retries
>>  }
>>  
>>  static int
>> +atusb_set_frame_retries(struct ieee802154_hw *hw, s8 retries)
>> +{
>> +	struct atusb *atusb = hw->priv;
>> +	struct device *dev = &atusb->usb_dev->dev;
>> +
>> +	if (atusb->fw_ver_maj == 0 && atusb->fw_ver_min < 3) {
>> +		dev_info(dev, "Automatic frame retransmission is only available from "
>> +			"firmware version 0.3. Please update if you want this feature.");
>> +		return -EINVAL;
>> +	}
>> +
> 
> I think the user has not change anymore to use atusb driver with new
> firmware now.
> 

meant, has no chance anymore to use new atusb driver with old
firmware...

- Alex

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH bluetooth-next 4/4] ieee802154: atusb: implement .set_frame_retries ops callback
  2016-12-20 11:13   ` Alexander Aring
  2016-12-20 11:21     ` Alexander Aring
@ 2017-01-02 15:01     ` Stefan Schmidt
  1 sibling, 0 replies; 9+ messages in thread
From: Stefan Schmidt @ 2017-01-02 15:01 UTC (permalink / raw)
  To: Alexander Aring; +Cc: linux-wpan

Hello.

On 20/12/16 12:13, Alexander Aring wrote:
>
> Hi,
>
> On 12/05/2016 02:47 PM, Stefan Schmidt wrote:
>> From firmware version 0.3 onwards we use the TX_ARET mode allowing for automatic
>> frame retransmissions. To actually make use of this feature we need to implement
>> the callback for setting the frame retries.
>>
>> If the firmware version is to old print a warning and return with invalid value.
>>
>> Signed-off-by: Stefan Schmidt <stefan@osg.samsung.com>
>> ---
>>  drivers/net/ieee802154/atusb.c | 19 ++++++++++++++++++-
>>  1 file changed, 18 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/net/ieee802154/atusb.c b/drivers/net/ieee802154/atusb.c
>> index 3ed34cc..1253f86 100644
>> --- a/drivers/net/ieee802154/atusb.c
>> +++ b/drivers/net/ieee802154/atusb.c
>> @@ -546,6 +546,21 @@ atusb_set_csma_params(struct ieee802154_hw *hw, u8 min_be, u8 max_be, u8 retries
>>  }
>>
>>  static int
>> +atusb_set_frame_retries(struct ieee802154_hw *hw, s8 retries)
>> +{
>> +	struct atusb *atusb = hw->priv;
>> +	struct device *dev = &atusb->usb_dev->dev;
>> +
>> +	if (atusb->fw_ver_maj == 0 && atusb->fw_ver_min < 3) {
>> +		dev_info(dev, "Automatic frame retransmission is only available from "
>> +			"firmware version 0.3. Please update if you want this feature.");
>> +		return -EINVAL;
>> +	}
>> +
>
> I think the user has not change anymore to use atusb driver with new
> firmware now.
>
> Because this will set _currently_ when one interface comes first time up.
> I say currently here, because we could change tx parameters on other
> way... we just need to be sure that no other tx is currently running
> anymore... and then change register values for tx parameters.
>
> One argument +1 to use xmit_async, with workqueue inside the driver we
> have no change to get knowledge about locking tx in upper-layer..., but
> this is another topic. :-)
>
>> +	return atusb_write_subreg(atusb, SR_MAX_FRAME_RETRIES, retries);
>> +}
>> +
>> +static int
>>  atusb_set_promiscuous_mode(struct ieee802154_hw *hw, const bool on)
>>  {
>>  	struct atusb *atusb = hw->priv;
>> @@ -584,6 +599,7 @@ static const struct ieee802154_ops atusb_ops = {
>>  	.set_cca_mode		= atusb_set_cca_mode,
>>  	.set_cca_ed_level	= atusb_set_cca_ed_level,
>>  	.set_csma_params	= atusb_set_csma_params,
>> +	.set_frame_retries	= atusb_set_frame_retries,
>>  	.set_promiscuous_mode	= atusb_set_promiscuous_mode,
>>  };
>>
>> @@ -754,7 +770,8 @@ static int atusb_probe(struct usb_interface *interface,
>>
>>  	hw->parent = &usb_dev->dev;
>>  	hw->flags = IEEE802154_HW_TX_OMIT_CKSUM | IEEE802154_HW_AFILT |
>> -		    IEEE802154_HW_PROMISCUOUS | IEEE802154_HW_CSMA_PARAMS;
>> +		    IEEE802154_HW_PROMISCUOUS | IEEE802154_HW_CSMA_PARAMS |
>> +		    IEEE802154_HW_FRAME_RETRIES;
>>
>
> You should set this flag only if it's new firmware... But not using
> TX_ARET has also other effects... It's good now that the firmware use
> TX_ARET per default.
>
> The current change is that old firmware users can't bring the interface
> anymore up, because it fails with -EINVAL and not chance to turn it off. :-)

Sorry for not catching this earlier. I tested with old and new firmware 
now and sent a patch that fixes this problem for me.

regards
Stefan Schmidt

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2017-01-02 15:01 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-05 13:47 [PATCH bluetooth-next 0/4] ieee802154: atusb: drivers updates for v0.3 firmware Stefan Schmidt
2016-12-05 13:47 ` [PATCH bluetooth-next 1/4] ieee802154: atusb: sync header file from firmware for new features Stefan Schmidt
2016-12-05 13:47 ` [PATCH bluetooth-next 2/4] ieee802154: atusb: store firmware version after retrieval for later use Stefan Schmidt
2016-12-05 13:47 ` [PATCH bluetooth-next 3/4] ieee802154: atusb: try to read permanent extended address from device Stefan Schmidt
2016-12-05 13:47 ` [PATCH bluetooth-next 4/4] ieee802154: atusb: implement .set_frame_retries ops callback Stefan Schmidt
2016-12-20 11:13   ` Alexander Aring
2016-12-20 11:21     ` Alexander Aring
2017-01-02 15:01     ` Stefan Schmidt
2016-12-08  7:05 ` [PATCH bluetooth-next 0/4] ieee802154: atusb: drivers updates for v0.3 firmware Marcel Holtmann

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.