Linux-Bluetooth Archive on lore.kernel.org
 help / Atom feed
* [PATCH v2 BlueZ] btmgmt: Add BREDR PHYs in PHY Configuration commands
@ 2018-11-09  6:37 Jaganath Kanakkassery
  2018-11-20 11:45 ` Jaganath K
  0 siblings, 1 reply; 4+ messages in thread
From: Jaganath Kanakkassery @ 2018-11-09  6:37 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Jaganath Kanakkassery

This basically adds BREDR packet types also in the PHY confiuration
commands & events and makes the PHYs 32 bit so that it can be
extended in future. This also add configurable PHYs in the GetPhy
command wherein only those can be selected or deselected in SetPhy.

This also adds LE prefix for LE phys to make it more
descriptive
---
 lib/mgmt.h     | 32 ++++++++++++++++---------
 tools/btmgmt.c | 75 ++++++++++++++++++++++++++++++++++------------------------
 2 files changed, 65 insertions(+), 42 deletions(-)

diff --git a/lib/mgmt.h b/lib/mgmt.h
index ec6a380..570dec9 100644
--- a/lib/mgmt.h
+++ b/lib/mgmt.h
@@ -552,16 +552,26 @@ struct mgmt_cp_set_appearance {
 
 #define MGMT_OP_GET_PHY_CONFIGURATION	0x0044
 struct mgmt_rp_get_phy_confguration {
-	uint16_t	supported_phys;
-	uint16_t	selected_phys;
-} __packed;
-
-#define MGMT_PHY_LE_1M_TX		0x0001
-#define MGMT_PHY_LE_1M_RX		0x0002
-#define MGMT_PHY_LE_2M_TX		0x0004
-#define MGMT_PHY_LE_2M_RX		0x0008
-#define MGMT_PHY_LE_CODED_TX		0x0010
-#define MGMT_PHY_LE_CODED_RX		0x0020
+	uint32_t	supported_phys;
+	uint32_t	configurable_phys;
+	uint32_t	selected_phys;
+} __packed;
+
+#define MGMT_PHY_BR_1M_1SLOT	0x00000001
+#define MGMT_PHY_BR_1M_3SLOT	0x00000002
+#define MGMT_PHY_BR_1M_5SLOT	0x00000004
+#define MGMT_PHY_EDR_2M_1SLOT	0x00000008
+#define MGMT_PHY_EDR_2M_3SLOT	0x00000010
+#define MGMT_PHY_EDR_2M_5SLOT	0x00000020
+#define MGMT_PHY_EDR_3M_1SLOT	0x00000040
+#define MGMT_PHY_EDR_3M_3SLOT	0x00000080
+#define MGMT_PHY_EDR_3M_5SLOT	0x00000100
+#define MGMT_PHY_LE_1M_TX		0x00000200
+#define MGMT_PHY_LE_1M_RX		0x00000400
+#define MGMT_PHY_LE_2M_TX		0x00000800
+#define MGMT_PHY_LE_2M_RX		0x00001000
+#define MGMT_PHY_LE_CODED_TX	0x00002000
+#define MGMT_PHY_LE_CODED_RX	0x00004000
 
 #define MGMT_PHY_LE_TX_MASK (MGMT_PHY_LE_1M_TX | MGMT_PHY_LE_2M_TX | \
 			     MGMT_PHY_LE_CODED_TX)
@@ -570,7 +580,7 @@ struct mgmt_rp_get_phy_confguration {
 
 #define MGMT_OP_SET_PHY_CONFIGURATION	0x0045
 struct mgmt_cp_set_phy_confguration {
-	uint16_t	default_phys;
+	uint32_t	selected_phys;
 } __packed;
 
 
diff --git a/tools/btmgmt.c b/tools/btmgmt.c
index 9e3a3ca..6922f3d 100644
--- a/tools/btmgmt.c
+++ b/tools/btmgmt.c
@@ -4181,15 +4181,24 @@ static void cmd_appearance(int argc, char **argv)
 }
 
 static const char *phys_str[] = {
-	"1MTX",
-	"1MRX",
-	"2MTX",
-	"2MRX",
-	"CODEDTX",
-	"CODEDRX",
+	"BR1M1SLOT",
+	"BR1M3SLOT",
+	"BR1M5SLOT",
+	"EDR2M1SLOT",
+	"EDR2M3SLOT",
+	"EDR2M5SLOT",
+	"EDR3M1SLOT",
+	"EDR3M3SLOT",
+	"EDR3M5SLOT",
+	"LE1MTX",
+	"LE1MRX",
+	"LE2MTX",
+	"LE2MRX",
+	"LECODEDTX",
+	"LECODEDRX",
 };
 
-static const char *phys2str(uint16_t phys)
+static const char *phys2str(uint32_t phys)
 {
 	static char str[256];
 	unsigned int i;
@@ -4207,11 +4216,25 @@ static const char *phys2str(uint16_t phys)
 	return str;
 }
 
+static bool str2phy(const char *phy_str, uint32_t *phy_val)
+{
+	unsigned int i;
+
+	for (i = 0; i < NELEM(phys_str); i++) {
+		if (strcasecmp(phys_str[i], phy_str) == 0) {
+			*phy_val = (1 << i);
+			return true;
+		}
+	}
+
+	return false;
+}
+
 static void get_phy_rsp(uint8_t status, uint16_t len, const void *param,
 							void *user_data)
 {
 	const struct mgmt_rp_get_phy_confguration *rp = param;
-	uint16_t supported_flags, selected_phys;
+	uint32_t supported_phys, selected_phys, configurable_phys;
 
 	if (status != 0) {
 		error("Get PHY Configuration failed with status 0x%02x (%s)",
@@ -4224,10 +4247,12 @@ static void get_phy_rsp(uint8_t status, uint16_t len, const void *param,
 		return bt_shell_noninteractive_quit(EXIT_FAILURE);
 	}
 
-	supported_flags = get_le16(&rp->supported_phys);
-	selected_phys = get_le16(&rp->selected_phys);
+	supported_phys = get_le32(&rp->supported_phys);
+	configurable_phys = get_le32(&rp->configurable_phys);
+	selected_phys = get_le32(&rp->selected_phys);
 
-	print("Supported phys: %s", phys2str(supported_flags));
+	print("Supported phys: %s", phys2str(supported_phys));
+	print("Configurable phys: %s", phys2str(configurable_phys));
 	print("Selected phys: %s", phys2str(selected_phys));
 
 	bt_shell_noninteractive_quit(EXIT_SUCCESS);
@@ -4266,33 +4291,20 @@ static void cmd_phy(int argc, char **argv)
 {
 	struct mgmt_cp_set_phy_confguration cp;
 	int i;
-	uint16_t phys = 0;
+	uint32_t phys = 0;
 	uint16_t index;
 
 	if (argc < 2)
 		return get_phy();
 
 	for (i = 1; i < argc; i++) {
-		if (strcasecmp(argv[i], "1MTX") == 0)
-			phys |= MGMT_PHY_LE_1M_TX;
-
-		if (strcasecmp(argv[i], "1MRX") == 0)
-			phys |= MGMT_PHY_LE_1M_RX;
-
-		if (strcasecmp(argv[i], "2MTX") == 0)
-			phys |= MGMT_PHY_LE_2M_TX;
-
-		if (strcasecmp(argv[i], "2MRX") == 0)
-			phys |= MGMT_PHY_LE_2M_RX;
-
-		if (strcasecmp(argv[i], "CODEDTX") == 0)
-			phys |= MGMT_PHY_LE_CODED_TX;
+		uint32_t phy_val;
 
-		if (strcasecmp(argv[i], "CODEDRX") == 0)
-			phys |= MGMT_PHY_LE_CODED_RX;
+		if (str2phy(argv[i], &phy_val))
+			phys |= phy_val;
 	}
 
-	cp.default_phys = cpu_to_le16(phys);
+	cp.selected_phys = cpu_to_le32(phys);
 
 	index = mgmt_index;
 	if (index == MGMT_INDEX_NONE)
@@ -4501,8 +4513,9 @@ static const struct bt_shell_menu main_menu = {
 		cmd_clr_adv,		"Clear advertising instances"	},
 	{ "appearance",		"<appearance>",
 		cmd_appearance,		"Set appearance"		},
-	{ "phy",		"[1MTX] [1MRX] [2MTX] [2MRX] [CODEDTX] "
-				"[CODEDRX] [BR1M1SLOT] [BR1M3SLOT] [BR1M5SLOT]"
+	{ "phy",		"[LE1MTX] [LE1MRX] [LE2MTX] [LE2MRX] "
+				"[LECODEDTX] [LECODEDRX] "
+				"[BR1M1SLOT] [BR1M3SLOT] [BR1M5SLOT]"
 				"[EDR2M1SLOT] [EDR2M3SLOT] [EDR2M5SLOT]"
 				"[EDR3M1SLOT] [EDR3M3SLOT] [EDR3M5SLOT]",
 		cmd_phy,		"Get/Set PHY Configuration"	},
-- 
2.7.4


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

* Re: [PATCH v2 BlueZ] btmgmt: Add BREDR PHYs in PHY Configuration commands
  2018-11-09  6:37 [PATCH v2 BlueZ] btmgmt: Add BREDR PHYs in PHY Configuration commands Jaganath Kanakkassery
@ 2018-11-20 11:45 ` Jaganath K
  2018-11-28  8:19   ` Jaganath K
  0 siblings, 1 reply; 4+ messages in thread
From: Jaganath K @ 2018-11-20 11:45 UTC (permalink / raw)
  To: open list:BLUETOOTH DRIVERS; +Cc: Jaganath Kanakkassery

Hi,

On Fri, Nov 9, 2018 at 12:13 PM Jaganath Kanakkassery
<jaganath.k.os@gmail.com> wrote:
>
> This basically adds BREDR packet types also in the PHY confiuration
> commands & events and makes the PHYs 32 bit so that it can be
> extended in future. This also add configurable PHYs in the GetPhy
> command wherein only those can be selected or deselected in SetPhy.
>
> This also adds LE prefix for LE phys to make it more
> descriptive
> ---
>  lib/mgmt.h     | 32 ++++++++++++++++---------
>  tools/btmgmt.c | 75 ++++++++++++++++++++++++++++++++++------------------------
>  2 files changed, 65 insertions(+), 42 deletions(-)
>
> diff --git a/lib/mgmt.h b/lib/mgmt.h
> index ec6a380..570dec9 100644
> --- a/lib/mgmt.h
> +++ b/lib/mgmt.h
> @@ -552,16 +552,26 @@ struct mgmt_cp_set_appearance {
>
>  #define MGMT_OP_GET_PHY_CONFIGURATION  0x0044
>  struct mgmt_rp_get_phy_confguration {
> -       uint16_t        supported_phys;
> -       uint16_t        selected_phys;
> -} __packed;
> -
> -#define MGMT_PHY_LE_1M_TX              0x0001
> -#define MGMT_PHY_LE_1M_RX              0x0002
> -#define MGMT_PHY_LE_2M_TX              0x0004
> -#define MGMT_PHY_LE_2M_RX              0x0008
> -#define MGMT_PHY_LE_CODED_TX           0x0010
> -#define MGMT_PHY_LE_CODED_RX           0x0020
> +       uint32_t        supported_phys;
> +       uint32_t        configurable_phys;
> +       uint32_t        selected_phys;
> +} __packed;
> +
> +#define MGMT_PHY_BR_1M_1SLOT   0x00000001
> +#define MGMT_PHY_BR_1M_3SLOT   0x00000002
> +#define MGMT_PHY_BR_1M_5SLOT   0x00000004
> +#define MGMT_PHY_EDR_2M_1SLOT  0x00000008
> +#define MGMT_PHY_EDR_2M_3SLOT  0x00000010
> +#define MGMT_PHY_EDR_2M_5SLOT  0x00000020
> +#define MGMT_PHY_EDR_3M_1SLOT  0x00000040
> +#define MGMT_PHY_EDR_3M_3SLOT  0x00000080
> +#define MGMT_PHY_EDR_3M_5SLOT  0x00000100
> +#define MGMT_PHY_LE_1M_TX              0x00000200
> +#define MGMT_PHY_LE_1M_RX              0x00000400
> +#define MGMT_PHY_LE_2M_TX              0x00000800
> +#define MGMT_PHY_LE_2M_RX              0x00001000
> +#define MGMT_PHY_LE_CODED_TX   0x00002000
> +#define MGMT_PHY_LE_CODED_RX   0x00004000
>
>  #define MGMT_PHY_LE_TX_MASK (MGMT_PHY_LE_1M_TX | MGMT_PHY_LE_2M_TX | \
>                              MGMT_PHY_LE_CODED_TX)
> @@ -570,7 +580,7 @@ struct mgmt_rp_get_phy_confguration {
>
>  #define MGMT_OP_SET_PHY_CONFIGURATION  0x0045
>  struct mgmt_cp_set_phy_confguration {
> -       uint16_t        default_phys;
> +       uint32_t        selected_phys;
>  } __packed;
>
>
> diff --git a/tools/btmgmt.c b/tools/btmgmt.c
> index 9e3a3ca..6922f3d 100644
> --- a/tools/btmgmt.c
> +++ b/tools/btmgmt.c
> @@ -4181,15 +4181,24 @@ static void cmd_appearance(int argc, char **argv)
>  }
>
>  static const char *phys_str[] = {
> -       "1MTX",
> -       "1MRX",
> -       "2MTX",
> -       "2MRX",
> -       "CODEDTX",
> -       "CODEDRX",
> +       "BR1M1SLOT",
> +       "BR1M3SLOT",
> +       "BR1M5SLOT",
> +       "EDR2M1SLOT",
> +       "EDR2M3SLOT",
> +       "EDR2M5SLOT",
> +       "EDR3M1SLOT",
> +       "EDR3M3SLOT",
> +       "EDR3M5SLOT",
> +       "LE1MTX",
> +       "LE1MRX",
> +       "LE2MTX",
> +       "LE2MRX",
> +       "LECODEDTX",
> +       "LECODEDRX",
>  };
>
> -static const char *phys2str(uint16_t phys)
> +static const char *phys2str(uint32_t phys)
>  {
>         static char str[256];
>         unsigned int i;
> @@ -4207,11 +4216,25 @@ static const char *phys2str(uint16_t phys)
>         return str;
>  }
>
> +static bool str2phy(const char *phy_str, uint32_t *phy_val)
> +{
> +       unsigned int i;
> +
> +       for (i = 0; i < NELEM(phys_str); i++) {
> +               if (strcasecmp(phys_str[i], phy_str) == 0) {
> +                       *phy_val = (1 << i);
> +                       return true;
> +               }
> +       }
> +
> +       return false;
> +}
> +
>  static void get_phy_rsp(uint8_t status, uint16_t len, const void *param,
>                                                         void *user_data)
>  {
>         const struct mgmt_rp_get_phy_confguration *rp = param;
> -       uint16_t supported_flags, selected_phys;
> +       uint32_t supported_phys, selected_phys, configurable_phys;
>
>         if (status != 0) {
>                 error("Get PHY Configuration failed with status 0x%02x (%s)",
> @@ -4224,10 +4247,12 @@ static void get_phy_rsp(uint8_t status, uint16_t len, const void *param,
>                 return bt_shell_noninteractive_quit(EXIT_FAILURE);
>         }
>
> -       supported_flags = get_le16(&rp->supported_phys);
> -       selected_phys = get_le16(&rp->selected_phys);
> +       supported_phys = get_le32(&rp->supported_phys);
> +       configurable_phys = get_le32(&rp->configurable_phys);
> +       selected_phys = get_le32(&rp->selected_phys);
>
> -       print("Supported phys: %s", phys2str(supported_flags));
> +       print("Supported phys: %s", phys2str(supported_phys));
> +       print("Configurable phys: %s", phys2str(configurable_phys));
>         print("Selected phys: %s", phys2str(selected_phys));
>
>         bt_shell_noninteractive_quit(EXIT_SUCCESS);
> @@ -4266,33 +4291,20 @@ static void cmd_phy(int argc, char **argv)
>  {
>         struct mgmt_cp_set_phy_confguration cp;
>         int i;
> -       uint16_t phys = 0;
> +       uint32_t phys = 0;
>         uint16_t index;
>
>         if (argc < 2)
>                 return get_phy();
>
>         for (i = 1; i < argc; i++) {
> -               if (strcasecmp(argv[i], "1MTX") == 0)
> -                       phys |= MGMT_PHY_LE_1M_TX;
> -
> -               if (strcasecmp(argv[i], "1MRX") == 0)
> -                       phys |= MGMT_PHY_LE_1M_RX;
> -
> -               if (strcasecmp(argv[i], "2MTX") == 0)
> -                       phys |= MGMT_PHY_LE_2M_TX;
> -
> -               if (strcasecmp(argv[i], "2MRX") == 0)
> -                       phys |= MGMT_PHY_LE_2M_RX;
> -
> -               if (strcasecmp(argv[i], "CODEDTX") == 0)
> -                       phys |= MGMT_PHY_LE_CODED_TX;
> +               uint32_t phy_val;
>
> -               if (strcasecmp(argv[i], "CODEDRX") == 0)
> -                       phys |= MGMT_PHY_LE_CODED_RX;
> +               if (str2phy(argv[i], &phy_val))
> +                       phys |= phy_val;
>         }
>
> -       cp.default_phys = cpu_to_le16(phys);
> +       cp.selected_phys = cpu_to_le32(phys);
>
>         index = mgmt_index;
>         if (index == MGMT_INDEX_NONE)
> @@ -4501,8 +4513,9 @@ static const struct bt_shell_menu main_menu = {
>                 cmd_clr_adv,            "Clear advertising instances"   },
>         { "appearance",         "<appearance>",
>                 cmd_appearance,         "Set appearance"                },
> -       { "phy",                "[1MTX] [1MRX] [2MTX] [2MRX] [CODEDTX] "
> -                               "[CODEDRX] [BR1M1SLOT] [BR1M3SLOT] [BR1M5SLOT]"
> +       { "phy",                "[LE1MTX] [LE1MRX] [LE2MTX] [LE2MRX] "
> +                               "[LECODEDTX] [LECODEDRX] "
> +                               "[BR1M1SLOT] [BR1M3SLOT] [BR1M5SLOT]"
>                                 "[EDR2M1SLOT] [EDR2M3SLOT] [EDR2M5SLOT]"
>                                 "[EDR3M1SLOT] [EDR3M3SLOT] [EDR3M5SLOT]",
>                 cmd_phy,                "Get/Set PHY Configuration"     },
> --

Ping.

Thanks,
Jaganath

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

* Re: [PATCH v2 BlueZ] btmgmt: Add BREDR PHYs in PHY Configuration commands
  2018-11-20 11:45 ` Jaganath K
@ 2018-11-28  8:19   ` Jaganath K
  2018-11-28  9:21     ` Luiz Augusto von Dentz
  0 siblings, 1 reply; 4+ messages in thread
From: Jaganath K @ 2018-11-28  8:19 UTC (permalink / raw)
  To: open list:BLUETOOTH DRIVERS; +Cc: Jaganath Kanakkassery

Hi,

On Tue, Nov 20, 2018 at 5:15 PM Jaganath K <jaganath.k.os@gmail.com> wrote:
>
> Hi,
>
> On Fri, Nov 9, 2018 at 12:13 PM Jaganath Kanakkassery
> <jaganath.k.os@gmail.com> wrote:
> >
> > This basically adds BREDR packet types also in the PHY confiuration
> > commands & events and makes the PHYs 32 bit so that it can be
> > extended in future. This also add configurable PHYs in the GetPhy
> > command wherein only those can be selected or deselected in SetPhy.
> >
> > This also adds LE prefix for LE phys to make it more
> > descriptive
> > ---
> >  lib/mgmt.h     | 32 ++++++++++++++++---------
> >  tools/btmgmt.c | 75 ++++++++++++++++++++++++++++++++++------------------------
> >  2 files changed, 65 insertions(+), 42 deletions(-)
> >
> > diff --git a/lib/mgmt.h b/lib/mgmt.h
> > index ec6a380..570dec9 100644
> > --- a/lib/mgmt.h
> > +++ b/lib/mgmt.h
> > @@ -552,16 +552,26 @@ struct mgmt_cp_set_appearance {
> >
> >  #define MGMT_OP_GET_PHY_CONFIGURATION  0x0044
> >  struct mgmt_rp_get_phy_confguration {
> > -       uint16_t        supported_phys;
> > -       uint16_t        selected_phys;
> > -} __packed;
> > -
> > -#define MGMT_PHY_LE_1M_TX              0x0001
> > -#define MGMT_PHY_LE_1M_RX              0x0002
> > -#define MGMT_PHY_LE_2M_TX              0x0004
> > -#define MGMT_PHY_LE_2M_RX              0x0008
> > -#define MGMT_PHY_LE_CODED_TX           0x0010
> > -#define MGMT_PHY_LE_CODED_RX           0x0020
> > +       uint32_t        supported_phys;
> > +       uint32_t        configurable_phys;
> > +       uint32_t        selected_phys;
> > +} __packed;
> > +
> > +#define MGMT_PHY_BR_1M_1SLOT   0x00000001
> > +#define MGMT_PHY_BR_1M_3SLOT   0x00000002
> > +#define MGMT_PHY_BR_1M_5SLOT   0x00000004
> > +#define MGMT_PHY_EDR_2M_1SLOT  0x00000008
> > +#define MGMT_PHY_EDR_2M_3SLOT  0x00000010
> > +#define MGMT_PHY_EDR_2M_5SLOT  0x00000020
> > +#define MGMT_PHY_EDR_3M_1SLOT  0x00000040
> > +#define MGMT_PHY_EDR_3M_3SLOT  0x00000080
> > +#define MGMT_PHY_EDR_3M_5SLOT  0x00000100
> > +#define MGMT_PHY_LE_1M_TX              0x00000200
> > +#define MGMT_PHY_LE_1M_RX              0x00000400
> > +#define MGMT_PHY_LE_2M_TX              0x00000800
> > +#define MGMT_PHY_LE_2M_RX              0x00001000
> > +#define MGMT_PHY_LE_CODED_TX   0x00002000
> > +#define MGMT_PHY_LE_CODED_RX   0x00004000
> >
> >  #define MGMT_PHY_LE_TX_MASK (MGMT_PHY_LE_1M_TX | MGMT_PHY_LE_2M_TX | \
> >                              MGMT_PHY_LE_CODED_TX)
> > @@ -570,7 +580,7 @@ struct mgmt_rp_get_phy_confguration {
> >
> >  #define MGMT_OP_SET_PHY_CONFIGURATION  0x0045
> >  struct mgmt_cp_set_phy_confguration {
> > -       uint16_t        default_phys;
> > +       uint32_t        selected_phys;
> >  } __packed;
> >
> >
> > diff --git a/tools/btmgmt.c b/tools/btmgmt.c
> > index 9e3a3ca..6922f3d 100644
> > --- a/tools/btmgmt.c
> > +++ b/tools/btmgmt.c
> > @@ -4181,15 +4181,24 @@ static void cmd_appearance(int argc, char **argv)
> >  }
> >
> >  static const char *phys_str[] = {
> > -       "1MTX",
> > -       "1MRX",
> > -       "2MTX",
> > -       "2MRX",
> > -       "CODEDTX",
> > -       "CODEDRX",
> > +       "BR1M1SLOT",
> > +       "BR1M3SLOT",
> > +       "BR1M5SLOT",
> > +       "EDR2M1SLOT",
> > +       "EDR2M3SLOT",
> > +       "EDR2M5SLOT",
> > +       "EDR3M1SLOT",
> > +       "EDR3M3SLOT",
> > +       "EDR3M5SLOT",
> > +       "LE1MTX",
> > +       "LE1MRX",
> > +       "LE2MTX",
> > +       "LE2MRX",
> > +       "LECODEDTX",
> > +       "LECODEDRX",
> >  };
> >
> > -static const char *phys2str(uint16_t phys)
> > +static const char *phys2str(uint32_t phys)
> >  {
> >         static char str[256];
> >         unsigned int i;
> > @@ -4207,11 +4216,25 @@ static const char *phys2str(uint16_t phys)
> >         return str;
> >  }
> >
> > +static bool str2phy(const char *phy_str, uint32_t *phy_val)
> > +{
> > +       unsigned int i;
> > +
> > +       for (i = 0; i < NELEM(phys_str); i++) {
> > +               if (strcasecmp(phys_str[i], phy_str) == 0) {
> > +                       *phy_val = (1 << i);
> > +                       return true;
> > +               }
> > +       }
> > +
> > +       return false;
> > +}
> > +
> >  static void get_phy_rsp(uint8_t status, uint16_t len, const void *param,
> >                                                         void *user_data)
> >  {
> >         const struct mgmt_rp_get_phy_confguration *rp = param;
> > -       uint16_t supported_flags, selected_phys;
> > +       uint32_t supported_phys, selected_phys, configurable_phys;
> >
> >         if (status != 0) {
> >                 error("Get PHY Configuration failed with status 0x%02x (%s)",
> > @@ -4224,10 +4247,12 @@ static void get_phy_rsp(uint8_t status, uint16_t len, const void *param,
> >                 return bt_shell_noninteractive_quit(EXIT_FAILURE);
> >         }
> >
> > -       supported_flags = get_le16(&rp->supported_phys);
> > -       selected_phys = get_le16(&rp->selected_phys);
> > +       supported_phys = get_le32(&rp->supported_phys);
> > +       configurable_phys = get_le32(&rp->configurable_phys);
> > +       selected_phys = get_le32(&rp->selected_phys);
> >
> > -       print("Supported phys: %s", phys2str(supported_flags));
> > +       print("Supported phys: %s", phys2str(supported_phys));
> > +       print("Configurable phys: %s", phys2str(configurable_phys));
> >         print("Selected phys: %s", phys2str(selected_phys));
> >
> >         bt_shell_noninteractive_quit(EXIT_SUCCESS);
> > @@ -4266,33 +4291,20 @@ static void cmd_phy(int argc, char **argv)
> >  {
> >         struct mgmt_cp_set_phy_confguration cp;
> >         int i;
> > -       uint16_t phys = 0;
> > +       uint32_t phys = 0;
> >         uint16_t index;
> >
> >         if (argc < 2)
> >                 return get_phy();
> >
> >         for (i = 1; i < argc; i++) {
> > -               if (strcasecmp(argv[i], "1MTX") == 0)
> > -                       phys |= MGMT_PHY_LE_1M_TX;
> > -
> > -               if (strcasecmp(argv[i], "1MRX") == 0)
> > -                       phys |= MGMT_PHY_LE_1M_RX;
> > -
> > -               if (strcasecmp(argv[i], "2MTX") == 0)
> > -                       phys |= MGMT_PHY_LE_2M_TX;
> > -
> > -               if (strcasecmp(argv[i], "2MRX") == 0)
> > -                       phys |= MGMT_PHY_LE_2M_RX;
> > -
> > -               if (strcasecmp(argv[i], "CODEDTX") == 0)
> > -                       phys |= MGMT_PHY_LE_CODED_TX;
> > +               uint32_t phy_val;
> >
> > -               if (strcasecmp(argv[i], "CODEDRX") == 0)
> > -                       phys |= MGMT_PHY_LE_CODED_RX;
> > +               if (str2phy(argv[i], &phy_val))
> > +                       phys |= phy_val;
> >         }
> >
> > -       cp.default_phys = cpu_to_le16(phys);
> > +       cp.selected_phys = cpu_to_le32(phys);
> >
> >         index = mgmt_index;
> >         if (index == MGMT_INDEX_NONE)
> > @@ -4501,8 +4513,9 @@ static const struct bt_shell_menu main_menu = {
> >                 cmd_clr_adv,            "Clear advertising instances"   },
> >         { "appearance",         "<appearance>",
> >                 cmd_appearance,         "Set appearance"                },
> > -       { "phy",                "[1MTX] [1MRX] [2MTX] [2MRX] [CODEDTX] "
> > -                               "[CODEDRX] [BR1M1SLOT] [BR1M3SLOT] [BR1M5SLOT]"
> > +       { "phy",                "[LE1MTX] [LE1MRX] [LE2MTX] [LE2MRX] "
> > +                               "[LECODEDTX] [LECODEDRX] "
> > +                               "[BR1M1SLOT] [BR1M3SLOT] [BR1M5SLOT]"
> >                                 "[EDR2M1SLOT] [EDR2M3SLOT] [EDR2M5SLOT]"
> >                                 "[EDR3M1SLOT] [EDR3M3SLOT] [EDR3M5SLOT]",
> >                 cmd_phy,                "Get/Set PHY Configuration"     },
> > --
>
> Ping.
>
Any update on this patch plz?.

Thanks,
Jaganath

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

* Re: [PATCH v2 BlueZ] btmgmt: Add BREDR PHYs in PHY Configuration commands
  2018-11-28  8:19   ` Jaganath K
@ 2018-11-28  9:21     ` Luiz Augusto von Dentz
  0 siblings, 0 replies; 4+ messages in thread
From: Luiz Augusto von Dentz @ 2018-11-28  9:21 UTC (permalink / raw)
  To: Jaganath Kanakkassery; +Cc: linux-bluetooth, Jaganath Kanakkassery

Hi Jaganath,
On Wed, Nov 28, 2018 at 10:22 AM Jaganath K <jaganath.k.os@gmail.com> wrote:
>
> Hi,
>
> On Tue, Nov 20, 2018 at 5:15 PM Jaganath K <jaganath.k.os@gmail.com> wrote:
> >
> > Hi,
> >
> > On Fri, Nov 9, 2018 at 12:13 PM Jaganath Kanakkassery
> > <jaganath.k.os@gmail.com> wrote:
> > >
> > > This basically adds BREDR packet types also in the PHY confiuration
> > > commands & events and makes the PHYs 32 bit so that it can be
> > > extended in future. This also add configurable PHYs in the GetPhy
> > > command wherein only those can be selected or deselected in SetPhy.
> > >
> > > This also adds LE prefix for LE phys to make it more
> > > descriptive
> > > ---
> > >  lib/mgmt.h     | 32 ++++++++++++++++---------
> > >  tools/btmgmt.c | 75 ++++++++++++++++++++++++++++++++++------------------------
> > >  2 files changed, 65 insertions(+), 42 deletions(-)
> > >
> > > diff --git a/lib/mgmt.h b/lib/mgmt.h
> > > index ec6a380..570dec9 100644
> > > --- a/lib/mgmt.h
> > > +++ b/lib/mgmt.h
> > > @@ -552,16 +552,26 @@ struct mgmt_cp_set_appearance {
> > >
> > >  #define MGMT_OP_GET_PHY_CONFIGURATION  0x0044
> > >  struct mgmt_rp_get_phy_confguration {
> > > -       uint16_t        supported_phys;
> > > -       uint16_t        selected_phys;
> > > -} __packed;
> > > -
> > > -#define MGMT_PHY_LE_1M_TX              0x0001
> > > -#define MGMT_PHY_LE_1M_RX              0x0002
> > > -#define MGMT_PHY_LE_2M_TX              0x0004
> > > -#define MGMT_PHY_LE_2M_RX              0x0008
> > > -#define MGMT_PHY_LE_CODED_TX           0x0010
> > > -#define MGMT_PHY_LE_CODED_RX           0x0020
> > > +       uint32_t        supported_phys;
> > > +       uint32_t        configurable_phys;
> > > +       uint32_t        selected_phys;
> > > +} __packed;
> > > +
> > > +#define MGMT_PHY_BR_1M_1SLOT   0x00000001
> > > +#define MGMT_PHY_BR_1M_3SLOT   0x00000002
> > > +#define MGMT_PHY_BR_1M_5SLOT   0x00000004
> > > +#define MGMT_PHY_EDR_2M_1SLOT  0x00000008
> > > +#define MGMT_PHY_EDR_2M_3SLOT  0x00000010
> > > +#define MGMT_PHY_EDR_2M_5SLOT  0x00000020
> > > +#define MGMT_PHY_EDR_3M_1SLOT  0x00000040
> > > +#define MGMT_PHY_EDR_3M_3SLOT  0x00000080
> > > +#define MGMT_PHY_EDR_3M_5SLOT  0x00000100
> > > +#define MGMT_PHY_LE_1M_TX              0x00000200
> > > +#define MGMT_PHY_LE_1M_RX              0x00000400
> > > +#define MGMT_PHY_LE_2M_TX              0x00000800
> > > +#define MGMT_PHY_LE_2M_RX              0x00001000
> > > +#define MGMT_PHY_LE_CODED_TX   0x00002000
> > > +#define MGMT_PHY_LE_CODED_RX   0x00004000
> > >
> > >  #define MGMT_PHY_LE_TX_MASK (MGMT_PHY_LE_1M_TX | MGMT_PHY_LE_2M_TX | \
> > >                              MGMT_PHY_LE_CODED_TX)
> > > @@ -570,7 +580,7 @@ struct mgmt_rp_get_phy_confguration {
> > >
> > >  #define MGMT_OP_SET_PHY_CONFIGURATION  0x0045
> > >  struct mgmt_cp_set_phy_confguration {
> > > -       uint16_t        default_phys;
> > > +       uint32_t        selected_phys;
> > >  } __packed;
> > >
> > >
> > > diff --git a/tools/btmgmt.c b/tools/btmgmt.c
> > > index 9e3a3ca..6922f3d 100644
> > > --- a/tools/btmgmt.c
> > > +++ b/tools/btmgmt.c
> > > @@ -4181,15 +4181,24 @@ static void cmd_appearance(int argc, char **argv)
> > >  }
> > >
> > >  static const char *phys_str[] = {
> > > -       "1MTX",
> > > -       "1MRX",
> > > -       "2MTX",
> > > -       "2MRX",
> > > -       "CODEDTX",
> > > -       "CODEDRX",
> > > +       "BR1M1SLOT",
> > > +       "BR1M3SLOT",
> > > +       "BR1M5SLOT",
> > > +       "EDR2M1SLOT",
> > > +       "EDR2M3SLOT",
> > > +       "EDR2M5SLOT",
> > > +       "EDR3M1SLOT",
> > > +       "EDR3M3SLOT",
> > > +       "EDR3M5SLOT",
> > > +       "LE1MTX",
> > > +       "LE1MRX",
> > > +       "LE2MTX",
> > > +       "LE2MRX",
> > > +       "LECODEDTX",
> > > +       "LECODEDRX",
> > >  };
> > >
> > > -static const char *phys2str(uint16_t phys)
> > > +static const char *phys2str(uint32_t phys)
> > >  {
> > >         static char str[256];
> > >         unsigned int i;
> > > @@ -4207,11 +4216,25 @@ static const char *phys2str(uint16_t phys)
> > >         return str;
> > >  }
> > >
> > > +static bool str2phy(const char *phy_str, uint32_t *phy_val)
> > > +{
> > > +       unsigned int i;
> > > +
> > > +       for (i = 0; i < NELEM(phys_str); i++) {
> > > +               if (strcasecmp(phys_str[i], phy_str) == 0) {
> > > +                       *phy_val = (1 << i);
> > > +                       return true;
> > > +               }
> > > +       }
> > > +
> > > +       return false;
> > > +}
> > > +
> > >  static void get_phy_rsp(uint8_t status, uint16_t len, const void *param,
> > >                                                         void *user_data)
> > >  {
> > >         const struct mgmt_rp_get_phy_confguration *rp = param;
> > > -       uint16_t supported_flags, selected_phys;
> > > +       uint32_t supported_phys, selected_phys, configurable_phys;
> > >
> > >         if (status != 0) {
> > >                 error("Get PHY Configuration failed with status 0x%02x (%s)",
> > > @@ -4224,10 +4247,12 @@ static void get_phy_rsp(uint8_t status, uint16_t len, const void *param,
> > >                 return bt_shell_noninteractive_quit(EXIT_FAILURE);
> > >         }
> > >
> > > -       supported_flags = get_le16(&rp->supported_phys);
> > > -       selected_phys = get_le16(&rp->selected_phys);
> > > +       supported_phys = get_le32(&rp->supported_phys);
> > > +       configurable_phys = get_le32(&rp->configurable_phys);
> > > +       selected_phys = get_le32(&rp->selected_phys);
> > >
> > > -       print("Supported phys: %s", phys2str(supported_flags));
> > > +       print("Supported phys: %s", phys2str(supported_phys));
> > > +       print("Configurable phys: %s", phys2str(configurable_phys));
> > >         print("Selected phys: %s", phys2str(selected_phys));
> > >
> > >         bt_shell_noninteractive_quit(EXIT_SUCCESS);
> > > @@ -4266,33 +4291,20 @@ static void cmd_phy(int argc, char **argv)
> > >  {
> > >         struct mgmt_cp_set_phy_confguration cp;
> > >         int i;
> > > -       uint16_t phys = 0;
> > > +       uint32_t phys = 0;
> > >         uint16_t index;
> > >
> > >         if (argc < 2)
> > >                 return get_phy();
> > >
> > >         for (i = 1; i < argc; i++) {
> > > -               if (strcasecmp(argv[i], "1MTX") == 0)
> > > -                       phys |= MGMT_PHY_LE_1M_TX;
> > > -
> > > -               if (strcasecmp(argv[i], "1MRX") == 0)
> > > -                       phys |= MGMT_PHY_LE_1M_RX;
> > > -
> > > -               if (strcasecmp(argv[i], "2MTX") == 0)
> > > -                       phys |= MGMT_PHY_LE_2M_TX;
> > > -
> > > -               if (strcasecmp(argv[i], "2MRX") == 0)
> > > -                       phys |= MGMT_PHY_LE_2M_RX;
> > > -
> > > -               if (strcasecmp(argv[i], "CODEDTX") == 0)
> > > -                       phys |= MGMT_PHY_LE_CODED_TX;
> > > +               uint32_t phy_val;
> > >
> > > -               if (strcasecmp(argv[i], "CODEDRX") == 0)
> > > -                       phys |= MGMT_PHY_LE_CODED_RX;
> > > +               if (str2phy(argv[i], &phy_val))
> > > +                       phys |= phy_val;
> > >         }
> > >
> > > -       cp.default_phys = cpu_to_le16(phys);
> > > +       cp.selected_phys = cpu_to_le32(phys);
> > >
> > >         index = mgmt_index;
> > >         if (index == MGMT_INDEX_NONE)
> > > @@ -4501,8 +4513,9 @@ static const struct bt_shell_menu main_menu = {
> > >                 cmd_clr_adv,            "Clear advertising instances"   },
> > >         { "appearance",         "<appearance>",
> > >                 cmd_appearance,         "Set appearance"                },
> > > -       { "phy",                "[1MTX] [1MRX] [2MTX] [2MRX] [CODEDTX] "
> > > -                               "[CODEDRX] [BR1M1SLOT] [BR1M3SLOT] [BR1M5SLOT]"
> > > +       { "phy",                "[LE1MTX] [LE1MRX] [LE2MTX] [LE2MRX] "
> > > +                               "[LECODEDTX] [LECODEDRX] "
> > > +                               "[BR1M1SLOT] [BR1M3SLOT] [BR1M5SLOT]"
> > >                                 "[EDR2M1SLOT] [EDR2M3SLOT] [EDR2M5SLOT]"
> > >                                 "[EDR3M1SLOT] [EDR3M3SLOT] [EDR3M5SLOT]",
> > >                 cmd_phy,                "Get/Set PHY Configuration"     },
> > > --
> >
> > Ping.
> >
> Any update on this patch plz?.

Applied, thanks.

-- 
Luiz Augusto von Dentz

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

end of thread, back to index

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-09  6:37 [PATCH v2 BlueZ] btmgmt: Add BREDR PHYs in PHY Configuration commands Jaganath Kanakkassery
2018-11-20 11:45 ` Jaganath K
2018-11-28  8:19   ` Jaganath K
2018-11-28  9:21     ` Luiz Augusto von Dentz

Linux-Bluetooth Archive on lore.kernel.org

Archives are clonable: git clone --mirror https://lore.kernel.org/linux-bluetooth/0 linux-bluetooth/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-bluetooth linux-bluetooth/ https://lore.kernel.org/linux-bluetooth \
		linux-bluetooth@vger.kernel.org linux-bluetooth@archiver.kernel.org
	public-inbox-index linux-bluetooth


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-bluetooth


AGPL code for this site: git clone https://public-inbox.org/ public-inbox