Pull networking updates from David Miller:
1) Significantly shrink the core networking routing structures. Result
of http://vger.kernel.org/~davem/seoul2017_netdev_keynote.pdf
2) Add netdevsim driver for testing various offloads, from Jakub
Kicinski.
3) Support cross-chip FDB operations in DSA, from Vivien Didelot.
4) Add a 2nd listener hash table for TCP, similar to what was done for
UDP. From Martin KaFai Lau.
5) Add eBPF based queue selection to tun, from Jason Wang.
6) Lockless qdisc support, from John Fastabend.
7) SCTP stream interleave support, from Xin Long.
8) Smoother TCP receive autotuning, from Eric Dumazet.
9) Lots of erspan tunneling enhancements, from William Tu.
10) Add true function call support to BPF, from Alexei Starovoitov.
11) Add explicit support for GRO HW offloading, from Michael Chan.
12) Support extack generation in more netlink subsystems. From Alexander
Aring, Quentin Monnet, and Jakub Kicinski.
13) Add 1000BaseX, flow control, and EEE support to mvneta driver. From
Russell King.
14) Add flow table abstraction to netfilter, from Pablo Neira Ayuso.
15) Many improvements and simplifications to the NFP driver bpf JIT,
from Jakub Kicinski.
16) Support for ipv6 non-equal cost multipath routing, from Ido
Schimmel.
17) Add resource abstration to devlink, from Arkadi Sharshevsky.
18) Packet scheduler classifier shared filter block support, from Jiri
Pirko.
19) Avoid locking in act_csum, from Davide Caratti.
20) devinet_ioctl() simplifications from Al viro.
21) More TCP bpf improvements from Lawrence Brakmo.
22) Add support for onlink ipv6 route flag, similar to ipv4, from David
Ahern.
* git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next: (1925 commits)
tls: Add support for encryption using async offload accelerator
ip6mr: fix stale iterator
net/sched: kconfig: Remove blank help texts
openvswitch: meter: Use 64-bit arithmetic instead of 32-bit
tcp_nv: fix potential integer overflow in tcpnv_acked
r8169: fix RTL8168EP take too long to complete driver initialization.
qmi_wwan: Add support for Quectel EP06
rtnetlink: enable IFLA_IF_NETNSID for RTM_NEWLINK
ipmr: Fix ptrdiff_t print formatting
ibmvnic: Wait for device response when changing MAC
qlcnic: fix deadlock bug
tcp: release sk_frag.page in tcp_disconnect
ipv4: Get the address of interface correctly.
net_sched: gen_estimator: fix lockdep splat
net: macb: Handle HRESP error
net/mlx5e: IPoIB, Fix copy-paste bug in flow steering refactoring
ipv6: addrconf: break critical section in addrconf_verify_rtnl()
ipv6: change route cache aging logic
i40e/i40evf: Update DESC_NEEDED value to reflect larger value
bnxt_en: cleanup DIM work on device shutdown
...
317 lines
10 KiB
C
317 lines
10 KiB
C
/*
|
|
* property.h - Unified device property interface.
|
|
*
|
|
* Copyright (C) 2014, Intel Corporation
|
|
* Authors: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
|
|
* Mika Westerberg <mika.westerberg@linux.intel.com>
|
|
*
|
|
* 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.
|
|
*/
|
|
|
|
#ifndef _LINUX_PROPERTY_H_
|
|
#define _LINUX_PROPERTY_H_
|
|
|
|
#include <linux/fwnode.h>
|
|
#include <linux/types.h>
|
|
|
|
struct device;
|
|
|
|
enum dev_prop_type {
|
|
DEV_PROP_U8,
|
|
DEV_PROP_U16,
|
|
DEV_PROP_U32,
|
|
DEV_PROP_U64,
|
|
DEV_PROP_STRING,
|
|
DEV_PROP_MAX,
|
|
};
|
|
|
|
enum dev_dma_attr {
|
|
DEV_DMA_NOT_SUPPORTED,
|
|
DEV_DMA_NON_COHERENT,
|
|
DEV_DMA_COHERENT,
|
|
};
|
|
|
|
struct fwnode_handle *dev_fwnode(struct device *dev);
|
|
|
|
bool device_property_present(struct device *dev, const char *propname);
|
|
int device_property_read_u8_array(struct device *dev, const char *propname,
|
|
u8 *val, size_t nval);
|
|
int device_property_read_u16_array(struct device *dev, const char *propname,
|
|
u16 *val, size_t nval);
|
|
int device_property_read_u32_array(struct device *dev, const char *propname,
|
|
u32 *val, size_t nval);
|
|
int device_property_read_u64_array(struct device *dev, const char *propname,
|
|
u64 *val, size_t nval);
|
|
int device_property_read_string_array(struct device *dev, const char *propname,
|
|
const char **val, size_t nval);
|
|
int device_property_read_string(struct device *dev, const char *propname,
|
|
const char **val);
|
|
int device_property_match_string(struct device *dev,
|
|
const char *propname, const char *string);
|
|
|
|
bool fwnode_device_is_available(const struct fwnode_handle *fwnode);
|
|
bool fwnode_property_present(const struct fwnode_handle *fwnode,
|
|
const char *propname);
|
|
int fwnode_property_read_u8_array(const struct fwnode_handle *fwnode,
|
|
const char *propname, u8 *val,
|
|
size_t nval);
|
|
int fwnode_property_read_u16_array(const struct fwnode_handle *fwnode,
|
|
const char *propname, u16 *val,
|
|
size_t nval);
|
|
int fwnode_property_read_u32_array(const struct fwnode_handle *fwnode,
|
|
const char *propname, u32 *val,
|
|
size_t nval);
|
|
int fwnode_property_read_u64_array(const struct fwnode_handle *fwnode,
|
|
const char *propname, u64 *val,
|
|
size_t nval);
|
|
int fwnode_property_read_string_array(const struct fwnode_handle *fwnode,
|
|
const char *propname, const char **val,
|
|
size_t nval);
|
|
int fwnode_property_read_string(const struct fwnode_handle *fwnode,
|
|
const char *propname, const char **val);
|
|
int fwnode_property_match_string(const struct fwnode_handle *fwnode,
|
|
const char *propname, const char *string);
|
|
int fwnode_property_get_reference_args(const struct fwnode_handle *fwnode,
|
|
const char *prop, const char *nargs_prop,
|
|
unsigned int nargs, unsigned int index,
|
|
struct fwnode_reference_args *args);
|
|
|
|
struct fwnode_handle *fwnode_get_parent(const struct fwnode_handle *fwnode);
|
|
struct fwnode_handle *fwnode_get_next_parent(
|
|
struct fwnode_handle *fwnode);
|
|
struct fwnode_handle *fwnode_get_next_child_node(
|
|
const struct fwnode_handle *fwnode, struct fwnode_handle *child);
|
|
struct fwnode_handle *fwnode_get_next_available_child_node(
|
|
const struct fwnode_handle *fwnode, struct fwnode_handle *child);
|
|
|
|
#define fwnode_for_each_child_node(fwnode, child) \
|
|
for (child = fwnode_get_next_child_node(fwnode, NULL); child; \
|
|
child = fwnode_get_next_child_node(fwnode, child))
|
|
|
|
#define fwnode_for_each_available_child_node(fwnode, child) \
|
|
for (child = fwnode_get_next_available_child_node(fwnode, NULL); child;\
|
|
child = fwnode_get_next_available_child_node(fwnode, child))
|
|
|
|
struct fwnode_handle *device_get_next_child_node(
|
|
struct device *dev, struct fwnode_handle *child);
|
|
|
|
#define device_for_each_child_node(dev, child) \
|
|
for (child = device_get_next_child_node(dev, NULL); child; \
|
|
child = device_get_next_child_node(dev, child))
|
|
|
|
struct fwnode_handle *fwnode_get_named_child_node(
|
|
const struct fwnode_handle *fwnode, const char *childname);
|
|
struct fwnode_handle *device_get_named_child_node(struct device *dev,
|
|
const char *childname);
|
|
|
|
struct fwnode_handle *fwnode_handle_get(struct fwnode_handle *fwnode);
|
|
void fwnode_handle_put(struct fwnode_handle *fwnode);
|
|
|
|
int fwnode_irq_get(struct fwnode_handle *fwnode, unsigned int index);
|
|
|
|
unsigned int device_get_child_node_count(struct device *dev);
|
|
|
|
static inline bool device_property_read_bool(struct device *dev,
|
|
const char *propname)
|
|
{
|
|
return device_property_present(dev, propname);
|
|
}
|
|
|
|
static inline int device_property_read_u8(struct device *dev,
|
|
const char *propname, u8 *val)
|
|
{
|
|
return device_property_read_u8_array(dev, propname, val, 1);
|
|
}
|
|
|
|
static inline int device_property_read_u16(struct device *dev,
|
|
const char *propname, u16 *val)
|
|
{
|
|
return device_property_read_u16_array(dev, propname, val, 1);
|
|
}
|
|
|
|
static inline int device_property_read_u32(struct device *dev,
|
|
const char *propname, u32 *val)
|
|
{
|
|
return device_property_read_u32_array(dev, propname, val, 1);
|
|
}
|
|
|
|
static inline int device_property_read_u64(struct device *dev,
|
|
const char *propname, u64 *val)
|
|
{
|
|
return device_property_read_u64_array(dev, propname, val, 1);
|
|
}
|
|
|
|
static inline bool fwnode_property_read_bool(const struct fwnode_handle *fwnode,
|
|
const char *propname)
|
|
{
|
|
return fwnode_property_present(fwnode, propname);
|
|
}
|
|
|
|
static inline int fwnode_property_read_u8(const struct fwnode_handle *fwnode,
|
|
const char *propname, u8 *val)
|
|
{
|
|
return fwnode_property_read_u8_array(fwnode, propname, val, 1);
|
|
}
|
|
|
|
static inline int fwnode_property_read_u16(const struct fwnode_handle *fwnode,
|
|
const char *propname, u16 *val)
|
|
{
|
|
return fwnode_property_read_u16_array(fwnode, propname, val, 1);
|
|
}
|
|
|
|
static inline int fwnode_property_read_u32(const struct fwnode_handle *fwnode,
|
|
const char *propname, u32 *val)
|
|
{
|
|
return fwnode_property_read_u32_array(fwnode, propname, val, 1);
|
|
}
|
|
|
|
static inline int fwnode_property_read_u64(const struct fwnode_handle *fwnode,
|
|
const char *propname, u64 *val)
|
|
{
|
|
return fwnode_property_read_u64_array(fwnode, propname, val, 1);
|
|
}
|
|
|
|
/**
|
|
* struct property_entry - "Built-in" device property representation.
|
|
* @name: Name of the property.
|
|
* @length: Length of data making up the value.
|
|
* @is_array: True when the property is an array.
|
|
* @is_string: True when property is a string.
|
|
* @pointer: Pointer to the property (an array of items of the given type).
|
|
* @value: Value of the property (when it is a single item of the given type).
|
|
*/
|
|
struct property_entry {
|
|
const char *name;
|
|
size_t length;
|
|
bool is_array;
|
|
bool is_string;
|
|
union {
|
|
union {
|
|
const void *raw_data;
|
|
const u8 *u8_data;
|
|
const u16 *u16_data;
|
|
const u32 *u32_data;
|
|
const u64 *u64_data;
|
|
const char * const *str;
|
|
} pointer;
|
|
union {
|
|
unsigned long long raw_data;
|
|
u8 u8_data;
|
|
u16 u16_data;
|
|
u32 u32_data;
|
|
u64 u64_data;
|
|
const char *str;
|
|
} value;
|
|
};
|
|
};
|
|
|
|
/*
|
|
* Note: the below four initializers for the anonymous union are carefully
|
|
* crafted to avoid gcc-4.4.4's problems with initialization of anon unions
|
|
* and structs.
|
|
*/
|
|
|
|
#define PROPERTY_ENTRY_INTEGER_ARRAY(_name_, _type_, _val_) \
|
|
{ \
|
|
.name = _name_, \
|
|
.length = ARRAY_SIZE(_val_) * sizeof(_type_), \
|
|
.is_array = true, \
|
|
.is_string = false, \
|
|
{ .pointer = { ._type_##_data = _val_ } }, \
|
|
}
|
|
|
|
#define PROPERTY_ENTRY_U8_ARRAY(_name_, _val_) \
|
|
PROPERTY_ENTRY_INTEGER_ARRAY(_name_, u8, _val_)
|
|
#define PROPERTY_ENTRY_U16_ARRAY(_name_, _val_) \
|
|
PROPERTY_ENTRY_INTEGER_ARRAY(_name_, u16, _val_)
|
|
#define PROPERTY_ENTRY_U32_ARRAY(_name_, _val_) \
|
|
PROPERTY_ENTRY_INTEGER_ARRAY(_name_, u32, _val_)
|
|
#define PROPERTY_ENTRY_U64_ARRAY(_name_, _val_) \
|
|
PROPERTY_ENTRY_INTEGER_ARRAY(_name_, u64, _val_)
|
|
|
|
#define PROPERTY_ENTRY_STRING_ARRAY(_name_, _val_) \
|
|
{ \
|
|
.name = _name_, \
|
|
.length = ARRAY_SIZE(_val_) * sizeof(const char *), \
|
|
.is_array = true, \
|
|
.is_string = true, \
|
|
{ .pointer = { .str = _val_ } }, \
|
|
}
|
|
|
|
#define PROPERTY_ENTRY_INTEGER(_name_, _type_, _val_) \
|
|
{ \
|
|
.name = _name_, \
|
|
.length = sizeof(_type_), \
|
|
.is_string = false, \
|
|
{ .value = { ._type_##_data = _val_ } }, \
|
|
}
|
|
|
|
#define PROPERTY_ENTRY_U8(_name_, _val_) \
|
|
PROPERTY_ENTRY_INTEGER(_name_, u8, _val_)
|
|
#define PROPERTY_ENTRY_U16(_name_, _val_) \
|
|
PROPERTY_ENTRY_INTEGER(_name_, u16, _val_)
|
|
#define PROPERTY_ENTRY_U32(_name_, _val_) \
|
|
PROPERTY_ENTRY_INTEGER(_name_, u32, _val_)
|
|
#define PROPERTY_ENTRY_U64(_name_, _val_) \
|
|
PROPERTY_ENTRY_INTEGER(_name_, u64, _val_)
|
|
|
|
#define PROPERTY_ENTRY_STRING(_name_, _val_) \
|
|
{ \
|
|
.name = _name_, \
|
|
.length = sizeof(_val_), \
|
|
.is_string = true, \
|
|
{ .value = { .str = _val_ } }, \
|
|
}
|
|
|
|
#define PROPERTY_ENTRY_BOOL(_name_) \
|
|
{ \
|
|
.name = _name_, \
|
|
}
|
|
|
|
struct property_entry *
|
|
property_entries_dup(const struct property_entry *properties);
|
|
|
|
void property_entries_free(const struct property_entry *properties);
|
|
|
|
int device_add_properties(struct device *dev,
|
|
const struct property_entry *properties);
|
|
void device_remove_properties(struct device *dev);
|
|
|
|
bool device_dma_supported(struct device *dev);
|
|
|
|
enum dev_dma_attr device_get_dma_attr(struct device *dev);
|
|
|
|
void *device_get_match_data(struct device *dev);
|
|
|
|
int device_get_phy_mode(struct device *dev);
|
|
|
|
void *device_get_mac_address(struct device *dev, char *addr, int alen);
|
|
|
|
int fwnode_get_phy_mode(struct fwnode_handle *fwnode);
|
|
void *fwnode_get_mac_address(struct fwnode_handle *fwnode,
|
|
char *addr, int alen);
|
|
struct fwnode_handle *fwnode_graph_get_next_endpoint(
|
|
const struct fwnode_handle *fwnode, struct fwnode_handle *prev);
|
|
struct fwnode_handle *
|
|
fwnode_graph_get_port_parent(const struct fwnode_handle *fwnode);
|
|
struct fwnode_handle *fwnode_graph_get_remote_port_parent(
|
|
const struct fwnode_handle *fwnode);
|
|
struct fwnode_handle *fwnode_graph_get_remote_port(
|
|
const struct fwnode_handle *fwnode);
|
|
struct fwnode_handle *fwnode_graph_get_remote_endpoint(
|
|
const struct fwnode_handle *fwnode);
|
|
struct fwnode_handle *
|
|
fwnode_graph_get_remote_node(const struct fwnode_handle *fwnode, u32 port,
|
|
u32 endpoint);
|
|
|
|
#define fwnode_graph_for_each_endpoint(fwnode, child) \
|
|
for (child = NULL; \
|
|
(child = fwnode_graph_get_next_endpoint(fwnode, child)); )
|
|
|
|
int fwnode_graph_parse_endpoint(const struct fwnode_handle *fwnode,
|
|
struct fwnode_endpoint *endpoint);
|
|
|
|
#endif /* _LINUX_PROPERTY_H_ */
|