wpan-tools: new netlink interfaces calls
Alexander Aring
maintainerv2 cover wpan-tools: new netlink interfaces calls
Hi all,
this patch series adds support for new netlink interfaces. For all new users on this mailinglist. This is the new userspace tool for the wpan rework [0] branch.
I removed the mib lock in the rework. Now you can only set the pan_id or short address (don't implement the setting of short address now) when the netdevice is _down_.
Then we don't need the the mib lock anymore. It's protected by RTNL if netdevice is down. When it's up it's a read only variable and we can use the variable in hot path like tx/rx without locking. (This is like setting and use of dev_addr of an netdev device).
I disabled the af802154 and security layer for now, but I will add this later at the end of the rework.
I also detected that our cca_mode handling is a driver specific netlink call. This is... not good. :-) And this is the current mainline behaviour...
In the rework I added enums for the 802.15.4 CCA_MODE numbers and now the at86rf231 makes a mapping from 802.15.4 specifc CCA_MODE to driver cca_mode( which is the register value).
I need to begin to write more text about the new behaviour, is there anybody outside who already test something?
We don't have the multiple phy layer, I dropped them. This was needed for the channel hoping. We need some new idea to provide a channel hoping logic, or simple but the logic for this in userspace. (You can change the channel while netdev is up).
There are several other netlink interfaces (setting short_address,setting energy detection value of phy)
The energy detection level is not part of the 802.15.4 pib, so this will be a direct call to the driver (not saving any value of this in the pib).
- Alex
[0] https://github.com/linux-wpan/linux-wpan-next/tree/wpan_rework_rfc
changes since v2:
- remove stolen LGPL code and reimplement a own header for unsupported netlink attributes of the netlink library. Maybe somebody should add it to netlink...
Alexander Aring (6):
nl_extras: initial commit for extra nl bindings
phy: add support for tx power pib attribute
phy: add support for setting cca_mode
mac: add support for setting max_frame_retries
mac: initial support for setting csma params
phy: add support for cca mode 3 and/or handling
src/mac.c | 113 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/nl802154.h | 20 ++++++++++ src/nl_extras.h | 36 ++++++++++++++++++ src/phy.c | 67 +++++++++++++++++++++++++++++++++ 4 files changed, 236 insertions(+) create mode 100644 src/nl_extras.h
Signature · 1 line
2.1.0
Alexander Aring
maintainerPATCH v2 1/6 nl_extras: initial commit for extra nl bindings
This header file is needed for additional signed bindings which are not in netlink library, currently.
--- src/nl_extras.h | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/nl_extras.h
src/nl_extras.h new file +36 -0
@@ -0,0 +1,36 @@ +#ifndef __NL_EXTRAS_H +#define __NL_EXTRAS_H + +#ifndef NLA_S8 + +#define NLA_S8 13 +#define NLA_PUT_S8 (n, attrtype, value) \ + NLA_PUT_TYPE(n, int8_t, attrtype, value) + +#endif /* NLA_S8 */ + +#ifndef NLA_S16 + +#define NLA_S16 14 +#define NLA_PUT_S16 (n, attrtype, value) \ + NLA_PUT_TYPE(n, int16_t, attrtype, value) + +#endif /* NLA_S16 */ + +#ifndef NLA_S32 + +#define NLA_S32 15 +#define NLA_PUT_S32 (n, attrtype, value) \ + NLA_PUT_TYPE(n, int32_t, attrtype, value) + +#endif /* NLA_S32 */ + +#ifndef NLA_S64 + +#define NLA_S64 16 +#define NLA_PUT_S64 (n, attrtype, value) \ + NLA_PUT_TYPE(n, int64_t, attrtype, value) + +#endif /* NLA_S64 */ + +#endif /* __NL_EXTRAS_H */
Signature · 1 line
2.1.0
Alexander Aring
maintainerRe: [PATCHv2 wpan-tools 1/6] nl_extras: initial commit for extra nl bindings
Hi Jiri Pirko,
I need a special header for my netlink application for introduce the signed integer types, which are not in current release of libnl.
First I took the headr from [0].
Then I saw it's LGPL, to avoid any code license issues I reimplement it now in my own header. It really looks the same, but putting my application to LGPL is out of question.
Now I want to be sure that you don't see a copy&paste and remove the license. Please let me know if this is okay for you.
- Alex
[0] https://github.com/jpirko/libteam/blob/master/libteam/nl_updates.h
Quoted 54 lines · Alexander Aring
This header file is needed for additional signed bindings which are not in netlink library, currently.
Signed-off-by Alexander Aring <[email protected]>--- src/nl_extras.h | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/nl_extras.hsrc/nl_extras.h new file +36
-0@@ -0,0 +1,36 @@ +#ifndef __NL_EXTRAS_H +#define __NL_EXTRAS_H + +#ifndef NLA_S8 + +#define NLA_S8 13 +#define NLA_PUT_S8 (n, attrtype, value) \ + NLA_PUT_TYPE(n, int8_t, attrtype, value) + +#endif /* NLA_S8 */ + +#ifndef NLA_S16 + +#define NLA_S16 14 +#define NLA_PUT_S16 (n, attrtype, value) \ + NLA_PUT_TYPE(n, int16_t, attrtype, value) + +#endif /* NLA_S16 */ + +#ifndef NLA_S32 + +#define NLA_S32 15 +#define NLA_PUT_S32 (n, attrtype, value) \ + NLA_PUT_TYPE(n, int32_t, attrtype, value) + +#endif /* NLA_S32 */ + +#ifndef NLA_S64 + +#define NLA_S64 16 +#define NLA_PUT_S64 (n, attrtype, value) \ + NLA_PUT_TYPE(n, int64_t, attrtype, value) + +#endif /* NLA_S64 */ + +#endif /* __NL_EXTRAS_H */ Signature · 1 line
2.1.0
Alexander Aring
maintainerPATCH v2 2/6 phy: add support for tx power pib attribute
In reply to Alexander Aring--- src/nl802154.h | 4 ++++ src/phy.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+)
src/nl802154.h +4 -0
@@ -43,6 +43,8 @@ enum nl802154_commands {NL802154_CMD_SET_PAN_ID , + NL802154_CMD_SET_TX_POWER, +/* add new commands above here */ /* used to define NL802154_CMD_MAX below */
@@ -71,6 +73,8 @@ enum nl802154_attrs {NL802154_ATTR_PAN_ID , +NL802154_ATTR_TX_POWER , +/* add attributes here, update the policy in nl802154.c */ __NL802154_ATTR_AFTER_LAST,
src/phy.c +28 -0
@@ -9,6 +9,7 @@#include <netlink/msg.h> #include <netlink/attr.h> +#include "nl_extras.h" #include "nl802154.h" #include "iwpan.h"
@@ -65,3 +66,30 @@ nla_put_failure: }COMMAND (set, channel,"<channel>" ,NL802154_CMD_SET_CHANNEL ,0 ,CIB_PHY , handle_channel_set,NULL ); + +static int handle_tx_power_set (struct nl802154_state *state, +struct nl_cb *cb, +struct nl_msg *msg, +int argc,char **argv, +enum id_input id) +{ +long dbm; +char *end; + +if (argc <1 ) +return 1 ; + +/* TX_POWER */ + dbm =strtol (argv[0 ], &end,10 ); +if (*end !='\0' ) +return 1 ; + +NLA_PUT_S8 (msg,NL802154_ATTR_TX_POWER , dbm); + +return 0 ; + +nla_put_failure: +return -ENOBUFS ; +} +COMMAND (set, tx_power,"<dBm>" , +NL802154_CMD_SET_TX_POWER ,0 ,CIB_PHY , handle_tx_power_set,NULL );
Signature · 1 line
2.1.0
Alexander Aring
maintainerPATCH v2 3/6 phy: add support for setting cca_mode
In reply to Alexander Aring--- src/nl802154.h | 3 +++ src/phy.c | 27 +++++++++++++++++++++++++++ 2 files changed, 30 insertions(+)
src/nl802154.h +3 -0
@@ -44,6 +44,7 @@ enum nl802154_commands {NL802154_CMD_SET_PAN_ID ,NL802154_CMD_SET_TX_POWER , + NL802154_CMD_SET_CCA_MODE,/* add new commands above here */
@@ -75,6 +76,8 @@ enum nl802154_attrs {NL802154_ATTR_TX_POWER , +NL802154_ATTR_CCA_MODE , +/* add attributes here, update the policy in nl802154.c */ __NL802154_ATTR_AFTER_LAST,
src/phy.c +27 -0
@@ -93,3 +93,30 @@ nla_put_failure: }COMMAND (set, tx_power,"<dBm>" ,NL802154_CMD_SET_TX_POWER ,0 ,CIB_PHY , handle_tx_power_set,NULL ); + +static int handle_cca_mode_set (struct nl802154_state *state, +struct nl_cb *cb, +struct nl_msg *msg, +int argc,char **argv, +enum id_input id) +{ +unsigned long cca_mode; +char *end; + +if (argc <1 ) +return 1 ; + +/* CCA_MODE */ + cca_mode =strtoul (argv[0 ], &end,10 ); +if (*end !='\0' ) +return 1 ; + +NLA_PUT_U8 (msg,NL802154_ATTR_CCA_MODE , cca_mode); + +return 0 ; + +nla_put_failure: +return -ENOBUFS ; +} +COMMAND (set, cca_mode,"<mode>" , +NL802154_CMD_SET_CCA_MODE ,0 ,CIB_PHY , handle_cca_mode_set,NULL );
Signature · 1 line
2.1.0
Alexander Aring
maintainerPATCH v2 4/6 mac: add support for setting max_frame_retries
In reply to Alexander Aring--- src/mac.c | 29 +++++++++++++++++++++++++++++ src/nl802154.h | 4 ++++ 2 files changed, 33 insertions(+)
src/mac.c +29 -0
@@ -9,6 +9,7 @@#include <netlink/msg.h> #include <netlink/attr.h> +#include "nl_extras.h" #include "nl802154.h" #include "iwpan.h"
@@ -38,3 +39,31 @@ nla_put_failure: }COMMAND (set, pan_id,"<pan_id>" ,NL802154_CMD_SET_PAN_ID ,0 ,CIB_NETDEV , handle_pan_id_set,NULL ); + +static int handle_max_frame_retries_set (struct nl802154_state *state, +struct nl_cb *cb, +struct nl_msg *msg, +int argc,char **argv, +enum id_input id) +{ +long retries; +char *end; + +if (argc <1 ) +return 1 ; + +/* RETRIES */ + retries =strtol (argv[0 ], &end,0 ); +if (*end !='\0' ) +return 1 ; + +NLA_PUT_S8 (msg,NL802154_ATTR_MAX_FRAME_RETRIES , retries); + +return 0 ; + +nla_put_failure: +return -ENOBUFS ; +} +COMMAND (set, max_frame_retries,"<retries>" , +NL802154_CMD_SET_MAX_FRAME_RETRIES ,0 ,CIB_NETDEV , + handle_max_frame_retries_set,NULL );
src/nl802154.h +4 -0
@@ -46,6 +46,8 @@ enum nl802154_commands {NL802154_CMD_SET_TX_POWER ,NL802154_CMD_SET_CCA_MODE , + NL802154_CMD_SET_MAX_FRAME_RETRIES, +/* add new commands above here */ /* used to define NL802154_CMD_MAX below */
@@ -78,6 +80,8 @@ enum nl802154_attrs {NL802154_ATTR_CCA_MODE , +NL802154_ATTR_MAX_FRAME_RETRIES , +/* add attributes here, update the policy in nl802154.c */ __NL802154_ATTR_AFTER_LAST,
Signature · 1 line
2.1.0
Alexander Aring
maintainerPATCH v2 5/6 mac: initial support for setting csma params
In reply to Alexander Aring--- src/mac.c | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/nl802154.h | 8 ++++++ 2 files changed, 92 insertions(+)
src/mac.c +84 -0
@@ -67,3 +67,87 @@ nla_put_failure:COMMAND (set, max_frame_retries,"<retries>" ,NL802154_CMD_SET_MAX_FRAME_RETRIES ,0 ,CIB_NETDEV , handle_max_frame_retries_set,NULL ); + +static int handle_max_be (struct nl802154_state *state, +struct nl_cb *cb, +struct nl_msg *msg, +int argc,char **argv, +enum id_input id) +{ +unsigned long max_be; +char *end; + +if (argc <1 ) +return 1 ; + +/* MAX_BE */ + max_be =strtoul (argv[0 ], &end,0 ); +if (*end !='\0' ) +return 1 ; + +NLA_PUT_U8 (msg,NL802154_ATTR_MAX_BE , max_be); + +return 0 ; + +nla_put_failure: +return -ENOBUFS ; +} +COMMAND (set, max_be,"<max_be>" , +NL802154_CMD_SET_MAX_BE ,0 ,CIB_NETDEV , + handle_max_be,NULL ); + +static int handle_max_csma_backoffs (struct nl802154_state *state, +struct nl_cb *cb, +struct nl_msg *msg, +int argc,char **argv, +enum id_input id) +{ +unsigned long backoffs; +char *end; + +if (argc <1 ) +return 1 ; + +/* BACKOFFS */ + backoffs =strtoul (argv[0 ], &end,0 ); +if (*end !='\0' ) +return 1 ; + +NLA_PUT_U8 (msg,NL802154_ATTR_MAX_CSMA_BACKOFFS , backoffs); + +return 0 ; + +nla_put_failure: +return -ENOBUFS ; +} +COMMAND (set, max_csma_backoffs,"<backoffs>" , +NL802154_CMD_SET_MAX_CSMA_BACKOFFS ,0 ,CIB_NETDEV , + handle_max_csma_backoffs,NULL ); + +static int handle_min_be (struct nl802154_state *state, +struct nl_cb *cb, +struct nl_msg *msg, +int argc,char **argv, +enum id_input id) +{ +unsigned long min_be; +char *end; + +if (argc <1 ) +return 1 ; + +/* MIN_BE */ + min_be =strtoul (argv[0 ], &end,0 ); +if (*end !='\0' ) +return 1 ; + +NLA_PUT_U8 (msg,NL802154_ATTR_MIN_BE , min_be); + +return 0 ; + +nla_put_failure: +return -ENOBUFS ; +} +COMMAND (set, min_be,"<min_be>" , +NL802154_CMD_SET_MIN_BE ,0 ,CIB_NETDEV , + handle_min_be,NULL );
src/nl802154.h +8 -0
@@ -48,6 +48,10 @@ enum nl802154_commands {NL802154_CMD_SET_MAX_FRAME_RETRIES , +NL802154_CMD_SET_MAX_BE , +NL802154_CMD_SET_MAX_CSMA_BACKOFFS , + NL802154_CMD_SET_MIN_BE, +/* add new commands above here */ /* used to define NL802154_CMD_MAX below */
@@ -82,6 +86,10 @@ enum nl802154_attrs {NL802154_ATTR_MAX_FRAME_RETRIES , +NL802154_ATTR_MAX_BE , +NL802154_ATTR_MAX_CSMA_BACKOFFS , +NL802154_ATTR_MIN_BE , +/* add attributes here, update the policy in nl802154.c */ __NL802154_ATTR_AFTER_LAST,
Signature · 1 line
2.1.0
Alexander Aring
maintainerPATCH v2 6/6 phy: add support for cca mode 3 and/or handling
In reply to Alexander Aring--- src/nl802154.h | 1 + src/phy.c | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-)
src/nl802154.h +1 -0
@@ -83,6 +83,7 @@ enum nl802154_attrs {NL802154_ATTR_TX_POWER ,NL802154_ATTR_CCA_MODE , +NL802154_ATTR_CCA_MODE3_AND , NL802154_ATTR_MAX_FRAME_RETRIES,
src/phy.c +14 -2
@@ -100,7 +100,7 @@ static int handle_cca_mode_set(struct nl802154_state *state, int argc, char **argv, enum id_input id) { - unsigned long cca_mode; + unsigned long cca_mode, cca_mode3_and;char *end;if (argc <1 )
@@ -111,6 +111,18 @@ static int handle_cca_mode_set(struct nl802154_state *state,if (*end !='\0' )return 1 ; +if (cca_mode ==3 ) { +if (argc <2 ) +return 1 ; + +/* CCA_MODE */ + cca_mode3_and =strtoul (argv[1 ], &end,10 ); +if (*end !='\0' ) +return 1 ; + +NLA_PUT_U8 (msg,NL802154_ATTR_CCA_MODE3_AND , cca_mode3_and); + } +NLA_PUT_U8 (msg,NL802154_ATTR_CCA_MODE , cca_mode);return 0 ;
@@ -118,5 +130,5 @@ static int handle_cca_mode_set(struct nl802154_state *state, nla_put_failure:return -ENOBUFS ; } -COMMAND (set, cca_mode,"<mode>" , +COMMAND (set, cca_mode,"<mode|3 <1|0>>" ,NL802154_CMD_SET_CCA_MODE ,0 ,CIB_PHY , handle_cca_mode_set,NULL );
Signature · 1 line
2.1.0