mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2025-01-13 15:47:06 +07:00
b92172661e
John W. Linville says: ==================== pull request: wireless-next 2014-11-07 Please pull this batch of updates intended for the 3.19 stream! For the mac80211 bits, Johannes says: "This relatively large batch of changes is comprised of the following: * large mac80211-hwsim changes from Ben, Jukka and a bit myself * OCB/WAVE/11p support from Rostislav on behalf of the Czech Technical University in Prague and Volkswagen Group Research * minstrel VHT work from Karl * more CSA work from Luca * WMM admission control support in mac80211 (myself) * various smaller fixes, spelling corrections, and minor API additions" For the Bluetooth bits, Johan says: "Here's the first bluetooth-next pull request for 3.19. The vast majority of patches are for ieee802154 from Alexander Aring with various fixes and cleanups. There are also several LE/SMP fixes as well as improved support for handling LE devices that have lost their pairing information (the patches from Alfonso). Jukka provides a couple of stability fixes for 6lowpan and Szymon conformance fixes for RFCOMM. For the HCI drivers we have one new USB ID for an Acer controller as well as a reset handling fix for H5." For the Atheros bits, Kalle says: "Major changes are: o ethtool support (Ben) o print dev string prefix with debug hex buffers dump (Michal) o debugfs file to read calibration data from the firmware verification purposes (me) o fix fw_stats debugfs file, now results are more reliable (Michal) o firmware crash counters via debugfs (Ben&me) o various tracing points to debug firmware (Rajkumar) o make it possible to provide firmware calibration data via a file (me) And we have quite a lot of smaller fixes and clean up." For the iwlwifi bits, Emmanuel says: "The big new thing here is netdetect which allows the firmware to wake up the platform when a specific network is detected. Along with that I have fixes for d3 operation. The usual amount of rate scaling stuff - we now support STBC. The other commit that stands out is Johannes's work on devcoredump. He basically starts to use the standard infrastructure he built." Along with that are the usual sort of updates and such for ath9k, brcmfmac, wil6210, and a handful of other bits here and there... Please let me know if there are problems! ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
272 lines
5.5 KiB
C
272 lines
5.5 KiB
C
/*
|
|
* Raw IEEE 802.15.4 sockets
|
|
*
|
|
* 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.
|
|
*
|
|
* Written by:
|
|
* Sergey Lapin <slapin@ossfans.org>
|
|
* Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
|
|
*/
|
|
|
|
#include <linux/net.h>
|
|
#include <linux/module.h>
|
|
#include <linux/if_arp.h>
|
|
#include <linux/list.h>
|
|
#include <linux/slab.h>
|
|
#include <net/sock.h>
|
|
#include <net/af_ieee802154.h>
|
|
#include <net/ieee802154_netdev.h>
|
|
|
|
#include "af802154.h"
|
|
|
|
static HLIST_HEAD(raw_head);
|
|
static DEFINE_RWLOCK(raw_lock);
|
|
|
|
static void raw_hash(struct sock *sk)
|
|
{
|
|
write_lock_bh(&raw_lock);
|
|
sk_add_node(sk, &raw_head);
|
|
sock_prot_inuse_add(sock_net(sk), sk->sk_prot, 1);
|
|
write_unlock_bh(&raw_lock);
|
|
}
|
|
|
|
static void raw_unhash(struct sock *sk)
|
|
{
|
|
write_lock_bh(&raw_lock);
|
|
if (sk_del_node_init(sk))
|
|
sock_prot_inuse_add(sock_net(sk), sk->sk_prot, -1);
|
|
write_unlock_bh(&raw_lock);
|
|
}
|
|
|
|
static void raw_close(struct sock *sk, long timeout)
|
|
{
|
|
sk_common_release(sk);
|
|
}
|
|
|
|
static int raw_bind(struct sock *sk, struct sockaddr *_uaddr, int len)
|
|
{
|
|
struct ieee802154_addr addr;
|
|
struct sockaddr_ieee802154 *uaddr = (struct sockaddr_ieee802154 *)_uaddr;
|
|
int err = 0;
|
|
struct net_device *dev = NULL;
|
|
|
|
if (len < sizeof(*uaddr))
|
|
return -EINVAL;
|
|
|
|
uaddr = (struct sockaddr_ieee802154 *)_uaddr;
|
|
if (uaddr->family != AF_IEEE802154)
|
|
return -EINVAL;
|
|
|
|
lock_sock(sk);
|
|
|
|
ieee802154_addr_from_sa(&addr, &uaddr->addr);
|
|
dev = ieee802154_get_dev(sock_net(sk), &addr);
|
|
if (!dev) {
|
|
err = -ENODEV;
|
|
goto out;
|
|
}
|
|
|
|
if (dev->type != ARPHRD_IEEE802154) {
|
|
err = -ENODEV;
|
|
goto out_put;
|
|
}
|
|
|
|
sk->sk_bound_dev_if = dev->ifindex;
|
|
sk_dst_reset(sk);
|
|
|
|
out_put:
|
|
dev_put(dev);
|
|
out:
|
|
release_sock(sk);
|
|
|
|
return err;
|
|
}
|
|
|
|
static int raw_connect(struct sock *sk, struct sockaddr *uaddr,
|
|
int addr_len)
|
|
{
|
|
return -ENOTSUPP;
|
|
}
|
|
|
|
static int raw_disconnect(struct sock *sk, int flags)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
static int raw_sendmsg(struct kiocb *iocb, struct sock *sk,
|
|
struct msghdr *msg, size_t size)
|
|
{
|
|
struct net_device *dev;
|
|
unsigned int mtu;
|
|
struct sk_buff *skb;
|
|
int hlen, tlen;
|
|
int err;
|
|
|
|
if (msg->msg_flags & MSG_OOB) {
|
|
pr_debug("msg->msg_flags = 0x%x\n", msg->msg_flags);
|
|
return -EOPNOTSUPP;
|
|
}
|
|
|
|
lock_sock(sk);
|
|
if (!sk->sk_bound_dev_if)
|
|
dev = dev_getfirstbyhwtype(sock_net(sk), ARPHRD_IEEE802154);
|
|
else
|
|
dev = dev_get_by_index(sock_net(sk), sk->sk_bound_dev_if);
|
|
release_sock(sk);
|
|
|
|
if (!dev) {
|
|
pr_debug("no dev\n");
|
|
err = -ENXIO;
|
|
goto out;
|
|
}
|
|
|
|
mtu = dev->mtu;
|
|
pr_debug("name = %s, mtu = %u\n", dev->name, mtu);
|
|
|
|
if (size > mtu) {
|
|
pr_debug("size = %Zu, mtu = %u\n", size, mtu);
|
|
err = -EINVAL;
|
|
goto out_dev;
|
|
}
|
|
|
|
hlen = LL_RESERVED_SPACE(dev);
|
|
tlen = dev->needed_tailroom;
|
|
skb = sock_alloc_send_skb(sk, hlen + tlen + size,
|
|
msg->msg_flags & MSG_DONTWAIT, &err);
|
|
if (!skb)
|
|
goto out_dev;
|
|
|
|
skb_reserve(skb, hlen);
|
|
|
|
skb_reset_mac_header(skb);
|
|
skb_reset_network_header(skb);
|
|
|
|
err = memcpy_fromiovec(skb_put(skb, size), msg->msg_iov, size);
|
|
if (err < 0)
|
|
goto out_skb;
|
|
|
|
skb->dev = dev;
|
|
skb->sk = sk;
|
|
skb->protocol = htons(ETH_P_IEEE802154);
|
|
|
|
dev_put(dev);
|
|
|
|
err = dev_queue_xmit(skb);
|
|
if (err > 0)
|
|
err = net_xmit_errno(err);
|
|
|
|
return err ?: size;
|
|
|
|
out_skb:
|
|
kfree_skb(skb);
|
|
out_dev:
|
|
dev_put(dev);
|
|
out:
|
|
return err;
|
|
}
|
|
|
|
static int raw_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
|
|
size_t len, int noblock, int flags, int *addr_len)
|
|
{
|
|
size_t copied = 0;
|
|
int err = -EOPNOTSUPP;
|
|
struct sk_buff *skb;
|
|
|
|
skb = skb_recv_datagram(sk, flags, noblock, &err);
|
|
if (!skb)
|
|
goto out;
|
|
|
|
copied = skb->len;
|
|
if (len < copied) {
|
|
msg->msg_flags |= MSG_TRUNC;
|
|
copied = len;
|
|
}
|
|
|
|
err = skb_copy_datagram_msg(skb, 0, msg, copied);
|
|
if (err)
|
|
goto done;
|
|
|
|
sock_recv_ts_and_drops(msg, sk, skb);
|
|
|
|
if (flags & MSG_TRUNC)
|
|
copied = skb->len;
|
|
done:
|
|
skb_free_datagram(sk, skb);
|
|
out:
|
|
if (err)
|
|
return err;
|
|
return copied;
|
|
}
|
|
|
|
static int raw_rcv_skb(struct sock *sk, struct sk_buff *skb)
|
|
{
|
|
skb = skb_share_check(skb, GFP_ATOMIC);
|
|
if (!skb)
|
|
return NET_RX_DROP;
|
|
|
|
if (sock_queue_rcv_skb(sk, skb) < 0) {
|
|
kfree_skb(skb);
|
|
return NET_RX_DROP;
|
|
}
|
|
|
|
return NET_RX_SUCCESS;
|
|
}
|
|
|
|
|
|
void ieee802154_raw_deliver(struct net_device *dev, struct sk_buff *skb)
|
|
{
|
|
struct sock *sk;
|
|
|
|
read_lock(&raw_lock);
|
|
sk_for_each(sk, &raw_head) {
|
|
bh_lock_sock(sk);
|
|
if (!sk->sk_bound_dev_if ||
|
|
sk->sk_bound_dev_if == dev->ifindex) {
|
|
struct sk_buff *clone;
|
|
|
|
clone = skb_clone(skb, GFP_ATOMIC);
|
|
if (clone)
|
|
raw_rcv_skb(sk, clone);
|
|
}
|
|
bh_unlock_sock(sk);
|
|
}
|
|
read_unlock(&raw_lock);
|
|
}
|
|
|
|
static int raw_getsockopt(struct sock *sk, int level, int optname,
|
|
char __user *optval, int __user *optlen)
|
|
{
|
|
return -EOPNOTSUPP;
|
|
}
|
|
|
|
static int raw_setsockopt(struct sock *sk, int level, int optname,
|
|
char __user *optval, unsigned int optlen)
|
|
{
|
|
return -EOPNOTSUPP;
|
|
}
|
|
|
|
struct proto ieee802154_raw_prot = {
|
|
.name = "IEEE-802.15.4-RAW",
|
|
.owner = THIS_MODULE,
|
|
.obj_size = sizeof(struct sock),
|
|
.close = raw_close,
|
|
.bind = raw_bind,
|
|
.sendmsg = raw_sendmsg,
|
|
.recvmsg = raw_recvmsg,
|
|
.hash = raw_hash,
|
|
.unhash = raw_unhash,
|
|
.connect = raw_connect,
|
|
.disconnect = raw_disconnect,
|
|
.getsockopt = raw_getsockopt,
|
|
.setsockopt = raw_setsockopt,
|
|
};
|