Lines Matching +full:phy +full:- +full:s

1 // SPDX-License-Identifier: GPL-2.0-only
9 * Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
25 #include "rdev-ops.h"
29 u32 seq, int flags, struct wpan_phy *phy) in ieee802154_nl_fill_phy() argument
35 pr_debug("%s\n", __func__); in ieee802154_nl_fill_phy()
38 return -EMSGSIZE; in ieee802154_nl_fill_phy()
46 if (nla_put_string(msg, IEEE802154_ATTR_PHY_NAME, wpan_phy_name(phy)) || in ieee802154_nl_fill_phy()
47 nla_put_u8(msg, IEEE802154_ATTR_PAGE, phy->current_page) || in ieee802154_nl_fill_phy()
48 nla_put_u8(msg, IEEE802154_ATTR_CHANNEL, phy->current_channel)) in ieee802154_nl_fill_phy()
51 if (phy->supported.channels[i]) in ieee802154_nl_fill_phy()
52 buf[pages++] = phy->supported.channels[i] | (i << 27); in ieee802154_nl_fill_phy()
68 return -EMSGSIZE; in ieee802154_nl_fill_phy()
77 struct wpan_phy *phy; in ieee802154_list_phy() local
79 int rc = -ENOBUFS; in ieee802154_list_phy()
81 pr_debug("%s\n", __func__); in ieee802154_list_phy()
83 if (!info->attrs[IEEE802154_ATTR_PHY_NAME]) in ieee802154_list_phy()
84 return -EINVAL; in ieee802154_list_phy()
86 name = nla_data(info->attrs[IEEE802154_ATTR_PHY_NAME]); in ieee802154_list_phy()
87 if (name[nla_len(info->attrs[IEEE802154_ATTR_PHY_NAME]) - 1] != '\0') in ieee802154_list_phy()
88 return -EINVAL; /* phy name should be null-terminated */ in ieee802154_list_phy()
90 phy = wpan_phy_find(name); in ieee802154_list_phy()
91 if (!phy) in ieee802154_list_phy()
92 return -ENODEV; in ieee802154_list_phy()
98 rc = ieee802154_nl_fill_phy(msg, info->snd_portid, info->snd_seq, in ieee802154_list_phy()
99 0, phy); in ieee802154_list_phy()
103 wpan_phy_put(phy); in ieee802154_list_phy()
109 wpan_phy_put(phy); in ieee802154_list_phy()
119 static int ieee802154_dump_phy_iter(struct wpan_phy *phy, void *_data) in ieee802154_dump_phy_iter() argument
124 pr_debug("%s\n", __func__); in ieee802154_dump_phy_iter()
126 if (data->idx++ < data->s_idx) in ieee802154_dump_phy_iter()
129 rc = ieee802154_nl_fill_phy(data->skb, in ieee802154_dump_phy_iter()
130 NETLINK_CB(data->cb->skb).portid, in ieee802154_dump_phy_iter()
131 data->cb->nlh->nlmsg_seq, in ieee802154_dump_phy_iter()
133 phy); in ieee802154_dump_phy_iter()
136 data->idx--; in ieee802154_dump_phy_iter()
148 .s_idx = cb->args[0], in ieee802154_dump_phy()
152 pr_debug("%s\n", __func__); in ieee802154_dump_phy()
156 cb->args[0] = data.idx; in ieee802154_dump_phy()
158 return skb->len; in ieee802154_dump_phy()
164 struct wpan_phy *phy; in ieee802154_add_iface() local
167 int rc = -ENOBUFS; in ieee802154_add_iface()
172 pr_debug("%s\n", __func__); in ieee802154_add_iface()
174 if (!info->attrs[IEEE802154_ATTR_PHY_NAME]) in ieee802154_add_iface()
175 return -EINVAL; in ieee802154_add_iface()
177 name = nla_data(info->attrs[IEEE802154_ATTR_PHY_NAME]); in ieee802154_add_iface()
178 if (name[nla_len(info->attrs[IEEE802154_ATTR_PHY_NAME]) - 1] != '\0') in ieee802154_add_iface()
179 return -EINVAL; /* phy name should be null-terminated */ in ieee802154_add_iface()
181 if (info->attrs[IEEE802154_ATTR_DEV_NAME]) { in ieee802154_add_iface()
182 devname = nla_data(info->attrs[IEEE802154_ATTR_DEV_NAME]); in ieee802154_add_iface()
183 if (devname[nla_len(info->attrs[IEEE802154_ATTR_DEV_NAME]) - 1] in ieee802154_add_iface()
185 return -EINVAL; /* phy name should be null-terminated */ in ieee802154_add_iface()
193 return -ENAMETOOLONG; in ieee802154_add_iface()
195 phy = wpan_phy_find(name); in ieee802154_add_iface()
196 if (!phy) in ieee802154_add_iface()
197 return -ENODEV; in ieee802154_add_iface()
203 if (info->attrs[IEEE802154_ATTR_HW_ADDR] && in ieee802154_add_iface()
204 nla_len(info->attrs[IEEE802154_ATTR_HW_ADDR]) != in ieee802154_add_iface()
206 rc = -EINVAL; in ieee802154_add_iface()
210 if (info->attrs[IEEE802154_ATTR_DEV_TYPE]) { in ieee802154_add_iface()
211 type = nla_get_u8(info->attrs[IEEE802154_ATTR_DEV_TYPE]); in ieee802154_add_iface()
213 rc = -EINVAL; in ieee802154_add_iface()
218 dev = rdev_add_virtual_intf_deprecated(wpan_phy_to_rdev(phy), devname, in ieee802154_add_iface()
226 if (info->attrs[IEEE802154_ATTR_HW_ADDR]) { in ieee802154_add_iface()
230 nla_memcpy(&addr.sa_data, info->attrs[IEEE802154_ATTR_HW_ADDR], in ieee802154_add_iface()
243 if (nla_put_string(msg, IEEE802154_ATTR_PHY_NAME, wpan_phy_name(phy)) || in ieee802154_add_iface()
244 nla_put_string(msg, IEEE802154_ATTR_DEV_NAME, dev->name)) { in ieee802154_add_iface()
245 rc = -EMSGSIZE; in ieee802154_add_iface()
250 wpan_phy_put(phy); in ieee802154_add_iface()
256 rdev_del_virtual_intf_deprecated(wpan_phy_to_rdev(phy), dev); in ieee802154_add_iface()
262 wpan_phy_put(phy); in ieee802154_add_iface()
269 struct wpan_phy *phy; in ieee802154_del_iface() local
274 pr_debug("%s\n", __func__); in ieee802154_del_iface()
276 if (!info->attrs[IEEE802154_ATTR_DEV_NAME]) in ieee802154_del_iface()
277 return -EINVAL; in ieee802154_del_iface()
279 name = nla_data(info->attrs[IEEE802154_ATTR_DEV_NAME]); in ieee802154_del_iface()
280 if (name[nla_len(info->attrs[IEEE802154_ATTR_DEV_NAME]) - 1] != '\0') in ieee802154_del_iface()
281 return -EINVAL; /* name should be null-terminated */ in ieee802154_del_iface()
283 rc = -ENODEV; in ieee802154_del_iface()
287 if (dev->type != ARPHRD_IEEE802154) in ieee802154_del_iface()
290 phy = dev->ieee802154_ptr->wpan_phy; in ieee802154_del_iface()
291 BUG_ON(!phy); in ieee802154_del_iface()
292 get_device(&phy->dev); in ieee802154_del_iface()
294 rc = -EINVAL; in ieee802154_del_iface()
295 /* phy name is optional, but should be checked if it's given */ in ieee802154_del_iface()
296 if (info->attrs[IEEE802154_ATTR_PHY_NAME]) { in ieee802154_del_iface()
300 nla_data(info->attrs[IEEE802154_ATTR_PHY_NAME]); in ieee802154_del_iface()
301 if (pname[nla_len(info->attrs[IEEE802154_ATTR_PHY_NAME]) - 1] in ieee802154_del_iface()
303 /* name should be null-terminated */ in ieee802154_del_iface()
310 if (phy != phy2) { in ieee802154_del_iface()
316 rc = -ENOBUFS; in ieee802154_del_iface()
323 rdev_del_virtual_intf_deprecated(wpan_phy_to_rdev(phy), dev); in ieee802154_del_iface()
331 if (nla_put_string(msg, IEEE802154_ATTR_PHY_NAME, wpan_phy_name(phy)) || in ieee802154_del_iface()
334 wpan_phy_put(phy); in ieee802154_del_iface()
341 wpan_phy_put(phy); in ieee802154_del_iface()