 9b2777d608
			
		
	
	
	9b2777d608
	
	
	
		
			
			Replace the current u8 transmit_power in wpan_phy with s8 transmit_power. The u8 field contained the actual tx power and a tolerance field, which no physical radio every used. Adjust sysfs entries to keep compatibility with userspace, give tolerances of +-1dB statically there. This patch only adds support for this in the at86rf230 driver and the RF212 chip. Configuration calculation for RF212 is also somewhat basic, but does the job - the RF212 datasheet gives a large table with suggested values for combinations of TX power and page/channel, if this does not work well, we might have to copy the whole table. Signed-off-by: Phoebe Buckheister <phoebe.buckheister@itwm.fraunhofer.de> Signed-off-by: David S. Miller <davem@davemloft.net>
		
			
				
	
	
		
			145 lines
		
	
	
	
		
			3.8 KiB
			
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			145 lines
		
	
	
	
		
			3.8 KiB
			
		
	
	
	
		
			C
		
	
	
	
	
	
| /*
 | |
|  * Netlink inteface for IEEE 802.15.4 stack
 | |
|  *
 | |
|  * Copyright 2007, 2008 Siemens AG
 | |
|  *
 | |
|  * This program is free software; you can redistribute it and/or modify
 | |
|  * it under the terms of the GNU General Public License version 2
 | |
|  * as published by the Free Software Foundation.
 | |
|  *
 | |
|  * This program is distributed in the hope that it will be useful,
 | |
|  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 | |
|  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | |
|  * GNU General Public License for more details.
 | |
|  *
 | |
|  * You should have received a copy of the GNU General Public License along
 | |
|  * with this program; if not, write to the Free Software Foundation, Inc.,
 | |
|  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 | |
|  *
 | |
|  * Written by:
 | |
|  * Sergey Lapin <slapin@ossfans.org>
 | |
|  * Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
 | |
|  * Maxim Osipov <maxim.osipov@siemens.com>
 | |
|  */
 | |
| 
 | |
| #include <linux/kernel.h>
 | |
| #include <linux/gfp.h>
 | |
| #include <net/genetlink.h>
 | |
| #include <linux/nl802154.h>
 | |
| 
 | |
| #include "ieee802154.h"
 | |
| 
 | |
| static unsigned int ieee802154_seq_num;
 | |
| static DEFINE_SPINLOCK(ieee802154_seq_lock);
 | |
| 
 | |
| struct genl_family nl802154_family = {
 | |
| 	.id		= GENL_ID_GENERATE,
 | |
| 	.hdrsize	= 0,
 | |
| 	.name		= IEEE802154_NL_NAME,
 | |
| 	.version	= 1,
 | |
| 	.maxattr	= IEEE802154_ATTR_MAX,
 | |
| };
 | |
| 
 | |
| /* Requests to userspace */
 | |
| struct sk_buff *ieee802154_nl_create(int flags, u8 req)
 | |
| {
 | |
| 	void *hdr;
 | |
| 	struct sk_buff *msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_ATOMIC);
 | |
| 	unsigned long f;
 | |
| 
 | |
| 	if (!msg)
 | |
| 		return NULL;
 | |
| 
 | |
| 	spin_lock_irqsave(&ieee802154_seq_lock, f);
 | |
| 	hdr = genlmsg_put(msg, 0, ieee802154_seq_num++,
 | |
| 			&nl802154_family, flags, req);
 | |
| 	spin_unlock_irqrestore(&ieee802154_seq_lock, f);
 | |
| 	if (!hdr) {
 | |
| 		nlmsg_free(msg);
 | |
| 		return NULL;
 | |
| 	}
 | |
| 
 | |
| 	return msg;
 | |
| }
 | |
| 
 | |
| int ieee802154_nl_mcast(struct sk_buff *msg, unsigned int group)
 | |
| {
 | |
| 	struct nlmsghdr *nlh = nlmsg_hdr(msg);
 | |
| 	void *hdr = genlmsg_data(nlmsg_data(nlh));
 | |
| 
 | |
| 	if (genlmsg_end(msg, hdr) < 0)
 | |
| 		goto out;
 | |
| 
 | |
| 	return genlmsg_multicast(&nl802154_family, msg, 0, group, GFP_ATOMIC);
 | |
| out:
 | |
| 	nlmsg_free(msg);
 | |
| 	return -ENOBUFS;
 | |
| }
 | |
| 
 | |
| struct sk_buff *ieee802154_nl_new_reply(struct genl_info *info,
 | |
| 		int flags, u8 req)
 | |
| {
 | |
| 	void *hdr;
 | |
| 	struct sk_buff *msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_ATOMIC);
 | |
| 
 | |
| 	if (!msg)
 | |
| 		return NULL;
 | |
| 
 | |
| 	hdr = genlmsg_put_reply(msg, info,
 | |
| 			&nl802154_family, flags, req);
 | |
| 	if (!hdr) {
 | |
| 		nlmsg_free(msg);
 | |
| 		return NULL;
 | |
| 	}
 | |
| 
 | |
| 	return msg;
 | |
| }
 | |
| 
 | |
| int ieee802154_nl_reply(struct sk_buff *msg, struct genl_info *info)
 | |
| {
 | |
| 	struct nlmsghdr *nlh = nlmsg_hdr(msg);
 | |
| 	void *hdr = genlmsg_data(nlmsg_data(nlh));
 | |
| 
 | |
| 	if (genlmsg_end(msg, hdr) < 0)
 | |
| 		goto out;
 | |
| 
 | |
| 	return genlmsg_reply(msg, info);
 | |
| out:
 | |
| 	nlmsg_free(msg);
 | |
| 	return -ENOBUFS;
 | |
| }
 | |
| 
 | |
| static const struct genl_ops ieee8021154_ops[] = {
 | |
| 	/* see nl-phy.c */
 | |
| 	IEEE802154_DUMP(IEEE802154_LIST_PHY, ieee802154_list_phy,
 | |
| 			ieee802154_dump_phy),
 | |
| 	IEEE802154_OP(IEEE802154_ADD_IFACE, ieee802154_add_iface),
 | |
| 	IEEE802154_OP(IEEE802154_DEL_IFACE, ieee802154_del_iface),
 | |
| 	IEEE802154_OP(IEEE802154_SET_PHYPARAMS, ieee802154_set_phyparams),
 | |
| 	/* see nl-mac.c */
 | |
| 	IEEE802154_OP(IEEE802154_ASSOCIATE_REQ, ieee802154_associate_req),
 | |
| 	IEEE802154_OP(IEEE802154_ASSOCIATE_RESP, ieee802154_associate_resp),
 | |
| 	IEEE802154_OP(IEEE802154_DISASSOCIATE_REQ, ieee802154_disassociate_req),
 | |
| 	IEEE802154_OP(IEEE802154_SCAN_REQ, ieee802154_scan_req),
 | |
| 	IEEE802154_OP(IEEE802154_START_REQ, ieee802154_start_req),
 | |
| 	IEEE802154_DUMP(IEEE802154_LIST_IFACE, ieee802154_list_iface,
 | |
| 			ieee802154_dump_iface),
 | |
| };
 | |
| 
 | |
| static const struct genl_multicast_group ieee802154_mcgrps[] = {
 | |
| 	[IEEE802154_COORD_MCGRP] = { .name = IEEE802154_MCAST_COORD_NAME, },
 | |
| 	[IEEE802154_BEACON_MCGRP] = { .name = IEEE802154_MCAST_BEACON_NAME, },
 | |
| };
 | |
| 
 | |
| 
 | |
| int __init ieee802154_nl_init(void)
 | |
| {
 | |
| 	return genl_register_family_with_ops_groups(&nl802154_family,
 | |
| 						    ieee8021154_ops,
 | |
| 						    ieee802154_mcgrps);
 | |
| }
 | |
| 
 | |
| void __exit ieee802154_nl_exit(void)
 | |
| {
 | |
| 	genl_unregister_family(&nl802154_family);
 | |
| }
 |