* [PATCH 17/20] batman-adv: Add kernel-doc to structs in headers
From: Simon Wunderlich @ 2017-12-15 11:43 UTC (permalink / raw)
To: davem; +Cc: netdev, b.a.t.m.a.n, Sven Eckelmann, Simon Wunderlich
In-Reply-To: <20171215114320.13645-1-sw@simonwunderlich.de>
From: Sven Eckelmann <sven@narfation.org>
All structs in types.h are already documented. But some other headers
still have private structs which also should be documented.
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
---
net/batman-adv/hash.h | 14 +++++++++++---
net/batman-adv/sysfs.h | 13 +++++++++++++
2 files changed, 24 insertions(+), 3 deletions(-)
diff --git a/net/batman-adv/hash.h b/net/batman-adv/hash.h
index 7647757d3660..239f394512b9 100644
--- a/net/batman-adv/hash.h
+++ b/net/batman-adv/hash.h
@@ -48,10 +48,18 @@ typedef bool (*batadv_hashdata_compare_cb)(const struct hlist_node *,
typedef u32 (*batadv_hashdata_choose_cb)(const void *, u32);
typedef void (*batadv_hashdata_free_cb)(struct hlist_node *, void *);
+/**
+ * struct batadv_hashtable - Wrapper of simple hlist based hashtable
+ */
struct batadv_hashtable {
- struct hlist_head *table; /* the hashtable itself with the buckets */
- spinlock_t *list_locks; /* spinlock for each hash list entry */
- u32 size; /* size of hashtable */
+ /** @table: the hashtable itself with the buckets */
+ struct hlist_head *table;
+
+ /** @list_locks: spinlock for each hash list entry */
+ spinlock_t *list_locks;
+
+ /** @size: size of hashtable */
+ u32 size;
};
/* allocates and clears the hash */
diff --git a/net/batman-adv/sysfs.h b/net/batman-adv/sysfs.h
index 0a3d41d52208..7cf7da70e1a5 100644
--- a/net/batman-adv/sysfs.h
+++ b/net/batman-adv/sysfs.h
@@ -38,10 +38,23 @@ struct net_device;
*/
#define BATADV_SYSFS_VLAN_SUBDIR_PREFIX "vlan"
+/**
+ * struct batadv_attribute - sysfs export helper for batman-adv attributes
+ */
struct batadv_attribute {
+ /** @attr: sysfs attribute file */
struct attribute attr;
+
+ /**
+ * @show: function to export the current attribute's content to sysfs
+ */
ssize_t (*show)(struct kobject *kobj, struct attribute *attr,
char *buf);
+
+ /**
+ * @store: function to load new value from character buffer and save it
+ * in batman-adv attribute
+ */
ssize_t (*store)(struct kobject *kobj, struct attribute *attr,
char *buf, size_t count);
};
--
2.11.0
^ permalink raw reply related
* [PATCH 16/20] batman-adv: Fix kernel-doc references to struct members
From: Simon Wunderlich @ 2017-12-15 11:43 UTC (permalink / raw)
To: davem; +Cc: netdev, b.a.t.m.a.n, Sven Eckelmann, Simon Wunderlich
In-Reply-To: <20171215114320.13645-1-sw@simonwunderlich.de>
From: Sven Eckelmann <sven@narfation.org>
The correct syntax to create references in kernel-doc to a struct member is
not "struct_name::member"" but "&struct_name->member" or
"&struct_name.member". The correct syntax is required to get the correct
cross-referencing in the reStructuredText text output.
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
---
net/batman-adv/types.h | 49 ++++++++++++++++++++++++++-----------------------
1 file changed, 26 insertions(+), 23 deletions(-)
diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
index cd68b30879d0..e4a79f9e2e24 100644
--- a/net/batman-adv/types.h
+++ b/net/batman-adv/types.h
@@ -236,7 +236,7 @@ struct batadv_hard_iface {
* struct batadv_orig_ifinfo - originator info per outgoing interface
*/
struct batadv_orig_ifinfo {
- /** @list: list node for orig_node::ifinfo_list */
+ /** @list: list node for &batadv_orig_node.ifinfo_list */
struct hlist_node list;
/** @if_outgoing: pointer to outgoing hard-interface */
@@ -322,7 +322,7 @@ struct batadv_orig_node_vlan {
/** @tt: VLAN specific TT attributes */
struct batadv_vlan_tt tt;
- /** @list: list node for orig_node::vlan_list */
+ /** @list: list node for &batadv_orig_node.vlan_list */
struct hlist_node list;
/**
@@ -469,7 +469,7 @@ struct batadv_orig_node {
*/
spinlock_t neigh_list_lock;
- /** @hash_entry: hlist node for batadv_priv::orig_hash */
+ /** @hash_entry: hlist node for &batadv_priv.orig_hash */
struct hlist_node hash_entry;
/** @bat_priv: pointer to soft_iface this orig node belongs to */
@@ -541,7 +541,7 @@ enum batadv_orig_capabilities {
* struct batadv_gw_node - structure for orig nodes announcing gw capabilities
*/
struct batadv_gw_node {
- /** @list: list node for batadv_priv_gw::list */
+ /** @list: list node for &batadv_priv_gw.list */
struct hlist_node list;
/** @orig_node: pointer to corresponding orig node */
@@ -590,7 +590,7 @@ struct batadv_hardif_neigh_node_bat_v {
* struct batadv_hardif_neigh_node - unique neighbor per hard-interface
*/
struct batadv_hardif_neigh_node {
- /** @list: list node for batadv_hard_iface::neigh_list */
+ /** @list: list node for &batadv_hard_iface.neigh_list */
struct hlist_node list;
/** @addr: the MAC address of the neighboring interface */
@@ -623,7 +623,7 @@ struct batadv_hardif_neigh_node {
* struct batadv_neigh_node - structure for single hops neighbors
*/
struct batadv_neigh_node {
- /** @list: list node for batadv_orig_node::neigh_list */
+ /** @list: list node for &batadv_orig_node.neigh_list */
struct hlist_node list;
/** @orig_node: pointer to corresponding orig_node */
@@ -699,7 +699,7 @@ struct batadv_neigh_ifinfo_bat_v {
* struct batadv_neigh_ifinfo - neighbor information per outgoing interface
*/
struct batadv_neigh_ifinfo {
- /** @list: list node for batadv_neigh_node::ifinfo_list */
+ /** @list: list node for &batadv_neigh_node.ifinfo_list */
struct hlist_node list;
/** @if_outgoing: pointer to outgoing hard-interface */
@@ -1310,7 +1310,7 @@ struct batadv_tp_unacked {
/** @len: length of the packet */
u16 len;
- /** @list: list node for batadv_tp_vars::unacked_list */
+ /** @list: list node for &batadv_tp_vars.unacked_list */
struct list_head list;
};
@@ -1329,7 +1329,7 @@ enum batadv_tp_meter_role {
* struct batadv_tp_vars - tp meter private variables per session
*/
struct batadv_tp_vars {
- /** @list: list node for bat_priv::tp_list */
+ /** @list: list node for &bat_priv.tp_list */
struct hlist_node list;
/** @timer: timer for ack (receiver) and retry (sender) */
@@ -1461,7 +1461,7 @@ struct batadv_softif_vlan {
/** @tt: TT private attributes (VLAN specific) */
struct batadv_vlan_tt tt;
- /** @list: list node for bat_priv::softif_vlan_list */
+ /** @list: list node for &bat_priv.softif_vlan_list */
struct hlist_node list;
/**
@@ -1729,7 +1729,7 @@ struct batadv_socket_client {
* struct batadv_socket_packet - layer2 icmp packet for socket client
*/
struct batadv_socket_packet {
- /** @list: list node for batadv_socket_client::queue_list */
+ /** @list: list node for &batadv_socket_client.queue_list */
struct list_head list;
/** @icmp_len: size of the layer2 icmp packet */
@@ -1754,7 +1754,7 @@ struct batadv_bla_backbone_gw {
/** @vid: vlan id this gateway was detected on */
unsigned short vid;
- /** @hash_entry: hlist node for batadv_priv_bla::backbone_hash */
+ /** @hash_entry: hlist node for &batadv_priv_bla.backbone_hash */
struct hlist_node hash_entry;
/** @bat_priv: pointer to soft_iface this backbone gateway belongs to */
@@ -1812,7 +1812,7 @@ struct batadv_bla_claim {
/** @lasttime: last time we heard of claim (locals only) */
unsigned long lasttime;
- /** @hash_entry: hlist node for batadv_priv_bla::claim_hash */
+ /** @hash_entry: hlist node for &batadv_priv_bla.claim_hash */
struct hlist_node hash_entry;
/** @refcount: number of contexts the object is used */
@@ -1834,8 +1834,8 @@ struct batadv_tt_common_entry {
unsigned short vid;
/**
- * @hash_entry: hlist node for batadv_priv_tt::local_hash or for
- * batadv_priv_tt::global_hash
+ * @hash_entry: hlist node for &batadv_priv_tt.local_hash or for
+ * &batadv_priv_tt.global_hash
*/
struct hlist_node hash_entry;
@@ -1902,7 +1902,7 @@ struct batadv_tt_orig_list_entry {
/** @flags: per orig entry TT sync flags */
u8 flags;
- /** @list: list node for batadv_tt_global_entry::orig_list */
+ /** @list: list node for &batadv_tt_global_entry.orig_list */
struct hlist_node list;
/** @refcount: number of contexts the object is used */
@@ -1916,7 +1916,7 @@ struct batadv_tt_orig_list_entry {
* struct batadv_tt_change_node - structure for tt changes occurred
*/
struct batadv_tt_change_node {
- /** @list: list node for batadv_priv_tt::changes_list */
+ /** @list: list node for &batadv_priv_tt.changes_list */
struct list_head list;
/** @change: holds the actual translation table diff data */
@@ -1938,7 +1938,7 @@ struct batadv_tt_req_node {
/** @refcount: number of contexts the object is used by */
struct kref refcount;
- /** @list: list node for batadv_priv_tt::req_list */
+ /** @list: list node for &batadv_priv_tt.req_list */
struct hlist_node list;
};
@@ -1960,7 +1960,7 @@ struct batadv_tt_roam_node {
*/
unsigned long first_time;
- /** @list: list node for batadv_priv_tt::roam_list */
+ /** @list: list node for &batadv_priv_tt.roam_list */
struct list_head list;
};
@@ -2062,7 +2062,10 @@ struct batadv_skb_cb {
* struct batadv_forw_packet - structure for bcast packets to be sent/forwarded
*/
struct batadv_forw_packet {
- /** @list: list node for batadv_priv::forw_{bat,bcast}_list */
+ /**
+ * @list: list node for &batadv_priv.forw.bcast_list and
+ * &batadv_priv.forw.bat_list
+ */
struct hlist_node list;
/** @cleanup_list: list node for purging functions */
@@ -2292,7 +2295,7 @@ struct batadv_dat_entry {
*/
unsigned long last_update;
- /** @hash_entry: hlist node for batadv_priv_dat::hash */
+ /** @hash_entry: hlist node for &batadv_priv_dat.hash */
struct hlist_node hash_entry;
/** @refcount: number of contexts the object is used */
@@ -2336,7 +2339,7 @@ struct batadv_dat_candidate {
* struct batadv_tvlv_container - container for tvlv appended to OGMs
*/
struct batadv_tvlv_container {
- /** @list: hlist node for batadv_priv_tvlv::container_list */
+ /** @list: hlist node for &batadv_priv_tvlv.container_list */
struct hlist_node list;
/** @tvlv_hdr: tvlv header information needed to construct the tvlv */
@@ -2350,7 +2353,7 @@ struct batadv_tvlv_container {
* struct batadv_tvlv_handler - handler for specific tvlv type and version
*/
struct batadv_tvlv_handler {
- /** @list: hlist node for batadv_priv_tvlv::handler_list */
+ /** @list: hlist node for &batadv_priv_tvlv.handler_list */
struct hlist_node list;
/**
--
2.11.0
^ permalink raw reply related
* [PATCH 19/20] batman-adv: Add kernel-doc to functions in headers
From: Simon Wunderlich @ 2017-12-15 11:43 UTC (permalink / raw)
To: davem; +Cc: netdev, b.a.t.m.a.n, Sven Eckelmann, Simon Wunderlich
In-Reply-To: <20171215114320.13645-1-sw@simonwunderlich.de>
From: Sven Eckelmann <sven@narfation.org>
Externally visible functions should be documented with kernel-doc. This
usually refers to non-static functions but also static inline files in
headers are visible in other files and should therefore be documented.
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
---
net/batman-adv/bitarray.h | 7 +++-
net/batman-adv/hard-interface.h | 6 +++
net/batman-adv/hash.h | 11 +++++-
net/batman-adv/log.h | 35 +++++++++++++++++-
net/batman-adv/main.h | 82 ++++++++++++++++++++++++++++++++++-------
net/batman-adv/originator.h | 9 ++++-
6 files changed, 131 insertions(+), 19 deletions(-)
diff --git a/net/batman-adv/bitarray.h b/net/batman-adv/bitarray.h
index 25c2cca948e3..611a609da80b 100644
--- a/net/batman-adv/bitarray.h
+++ b/net/batman-adv/bitarray.h
@@ -49,7 +49,12 @@ static inline bool batadv_test_bit(const unsigned long *seq_bits,
return test_bit(diff, seq_bits) != 0;
}
-/* turn corresponding bit on, so we can remember that we got the packet */
+/**
+ * batadv_set_bit() - Turn corresponding bit on, so we can remember that we got
+ * the packet
+ * @seq_bits: bitmap of the packet receive window
+ * @n: relative sequence number of newly received packet
+ */
static inline void batadv_set_bit(unsigned long *seq_bits, s32 n)
{
/* if too old, just drop it */
diff --git a/net/batman-adv/hard-interface.h b/net/batman-adv/hard-interface.h
index f29974b487cc..52cdc7efbf97 100644
--- a/net/batman-adv/hard-interface.h
+++ b/net/batman-adv/hard-interface.h
@@ -132,6 +132,12 @@ static inline void batadv_hardif_put(struct batadv_hard_iface *hard_iface)
kref_put(&hard_iface->refcount, batadv_hardif_release);
}
+/**
+ * batadv_primary_if_get_selected() - Get reference to primary interface
+ * @bat_priv: the bat priv with all the soft interface information
+ *
+ * Return: primary interface (with increased refcnt), otherwise NULL
+ */
static inline struct batadv_hard_iface *
batadv_primary_if_get_selected(struct batadv_priv *bat_priv)
{
diff --git a/net/batman-adv/hash.h b/net/batman-adv/hash.h
index 239f394512b9..29a2842c4ed8 100644
--- a/net/batman-adv/hash.h
+++ b/net/batman-adv/hash.h
@@ -123,8 +123,15 @@ static inline int batadv_hash_add(struct batadv_hashtable *hash,
return ret;
}
-/* removes data from hash, if found. data could be the structure you use with
- * just the key filled, we just need the key for comparing.
+/**
+ * batadv_hash_remove() - Removes data from hash, if found
+ * @hash: hash table
+ * @compare: callback to determine if 2 hash elements are identical
+ * @choose: callback calculating the hash index
+ * @data: data passed to the aforementioned callbacks as argument
+ *
+ * ata could be the structure you use with just the key filled, we just need
+ * the key for comparing.
*
* Return: returns pointer do data on success, so you can remove the used
* structure yourself, or NULL on error
diff --git a/net/batman-adv/log.h b/net/batman-adv/log.h
index 67e25121a4de..09d457e385fe 100644
--- a/net/batman-adv/log.h
+++ b/net/batman-adv/log.h
@@ -81,7 +81,14 @@ enum batadv_dbg_level {
int batadv_debug_log(struct batadv_priv *bat_priv, const char *fmt, ...)
__printf(2, 3);
-/* possibly ratelimited debug output */
+/**
+ * _batadv_dbg() - Store debug output with(out) ratelimiting
+ * @type: type of debug message
+ * @bat_priv: the bat priv with all the soft interface information
+ * @ratelimited: whether output should be rate limited
+ * @fmt: format string
+ * @arg...: variable arguments
+ */
#define _batadv_dbg(type, bat_priv, ratelimited, fmt, arg...) \
do { \
struct batadv_priv *__batpriv = (bat_priv); \
@@ -100,11 +107,30 @@ static inline void _batadv_dbg(int type __always_unused,
}
#endif
+/**
+ * batadv_dbg() - Store debug output without ratelimiting
+ * @type: type of debug message
+ * @bat_priv: the bat priv with all the soft interface information
+ * @arg...: format string and variable arguments
+ */
#define batadv_dbg(type, bat_priv, arg...) \
_batadv_dbg(type, bat_priv, 0, ## arg)
+
+/**
+ * batadv_dbg_ratelimited() - Store debug output with ratelimiting
+ * @type: type of debug message
+ * @bat_priv: the bat priv with all the soft interface information
+ * @arg...: format string and variable arguments
+ */
#define batadv_dbg_ratelimited(type, bat_priv, arg...) \
_batadv_dbg(type, bat_priv, 1, ## arg)
+/**
+ * batadv_info() - Store message in debug buffer and print it to kmsg buffer
+ * @net_dev: the soft interface net device
+ * @fmt: format string
+ * @arg...: variable arguments
+ */
#define batadv_info(net_dev, fmt, arg...) \
do { \
struct net_device *_netdev = (net_dev); \
@@ -112,6 +138,13 @@ static inline void _batadv_dbg(int type __always_unused,
batadv_dbg(BATADV_DBG_ALL, _batpriv, fmt, ## arg); \
pr_info("%s: " fmt, _netdev->name, ## arg); \
} while (0)
+
+/**
+ * batadv_err() - Store error in debug buffer and print it to kmsg buffer
+ * @net_dev: the soft interface net device
+ * @fmt: format string
+ * @arg...: variable arguments
+ */
#define batadv_err(net_dev, fmt, arg...) \
do { \
struct net_device *_netdev = (net_dev); \
diff --git a/net/batman-adv/main.h b/net/batman-adv/main.h
index 53f386bedd3b..69c2ab666961 100644
--- a/net/batman-adv/main.h
+++ b/net/batman-adv/main.h
@@ -300,40 +300,96 @@ static inline bool batadv_has_timed_out(unsigned long timestamp,
return time_is_before_jiffies(timestamp + msecs_to_jiffies(timeout));
}
+/**
+ * batadv_atomic_dec_not_zero() - Decrease unless the number is 0
+ * @v: pointer of type atomic_t
+ *
+ * Return: non-zero if v was not 0, and zero otherwise.
+ */
#define batadv_atomic_dec_not_zero(v) atomic_add_unless((v), -1, 0)
-/* Returns the smallest signed integer in two's complement with the sizeof x */
+/**
+ * batadv_smallest_signed_int() - Returns the smallest signed integer in two's
+ * complement with the sizeof x
+ * @x: type of integer
+ *
+ * Return: smallest signed integer of type
+ */
#define batadv_smallest_signed_int(x) (1u << (7u + 8u * (sizeof(x) - 1u)))
-/* Checks if a sequence number x is a predecessor/successor of y.
- * they handle overflows/underflows and can correctly check for a
- * predecessor/successor unless the variable sequence number has grown by
- * more then 2**(bitwidth(x)-1)-1.
+/**
+ * batadv_seq_before() - Checks if a sequence number x is a predecessor of y
+ * @x: potential predecessor of @y
+ * @y: value to compare @x against
+ *
+ * It handles overflows/underflows and can correctly check for a predecessor
+ * unless the variable sequence number has grown by more then
+ * 2**(bitwidth(x)-1)-1.
+ *
* This means that for a u8 with the maximum value 255, it would think:
- * - when adding nothing - it is neither a predecessor nor a successor
- * - before adding more than 127 to the starting value - it is a predecessor,
- * - when adding 128 - it is neither a predecessor nor a successor,
- * - after adding more than 127 to the starting value - it is a successor
+ *
+ * * when adding nothing - it is neither a predecessor nor a successor
+ * * before adding more than 127 to the starting value - it is a predecessor,
+ * * when adding 128 - it is neither a predecessor nor a successor,
+ * * after adding more than 127 to the starting value - it is a successor
+ *
+ * Return: true when x is a predecessor of y, false otherwise
*/
#define batadv_seq_before(x, y) ({typeof(x)_d1 = (x); \
typeof(y)_d2 = (y); \
typeof(x)_dummy = (_d1 - _d2); \
(void)(&_d1 == &_d2); \
_dummy > batadv_smallest_signed_int(_dummy); })
+
+/**
+ * batadv_seq_after() - Checks if a sequence number x is a successor of y
+ * @x: potential sucessor of @y
+ * @y: value to compare @x against
+ *
+ * It handles overflows/underflows and can correctly check for a successor
+ * unless the variable sequence number has grown by more then
+ * 2**(bitwidth(x)-1)-1.
+ *
+ * This means that for a u8 with the maximum value 255, it would think:
+ *
+ * * when adding nothing - it is neither a predecessor nor a successor
+ * * before adding more than 127 to the starting value - it is a predecessor,
+ * * when adding 128 - it is neither a predecessor nor a successor,
+ * * after adding more than 127 to the starting value - it is a successor
+ *
+ * Return: true when x is a successor of y, false otherwise
+ */
#define batadv_seq_after(x, y) batadv_seq_before(y, x)
-/* Stop preemption on local cpu while incrementing the counter */
+/**
+ * batadv_add_counter() - Add to per cpu statistics counter of soft interface
+ * @bat_priv: the bat priv with all the soft interface information
+ * @idx: counter index which should be modified
+ * @count: value to increase counter by
+ *
+ * Stop preemption on local cpu while incrementing the counter
+ */
static inline void batadv_add_counter(struct batadv_priv *bat_priv, size_t idx,
size_t count)
{
this_cpu_add(bat_priv->bat_counters[idx], count);
}
+/**
+ * batadv_inc_counter() - Increase per cpu statistics counter of soft interface
+ * @b: the bat priv with all the soft interface information
+ * @i: counter index which should be modified
+ */
#define batadv_inc_counter(b, i) batadv_add_counter(b, i, 1)
-/* Define a macro to reach the control buffer of the skb. The members of the
- * control buffer are defined in struct batadv_skb_cb in types.h.
- * The macro is inspired by the similar macro TCP_SKB_CB() in tcp.h.
+/**
+ * BATADV_SKB_CB() - Get batadv_skb_cb from skb control buffer
+ * @__skb: skb holding the control buffer
+ *
+ * The members of the control buffer are defined in struct batadv_skb_cb in
+ * types.h. The macro is inspired by the similar macro TCP_SKB_CB() in tcp.h.
+ *
+ * Return: pointer to the batadv_skb_cb of the skb
*/
#define BATADV_SKB_CB(__skb) ((struct batadv_skb_cb *)&((__skb)->cb[0]))
diff --git a/net/batman-adv/originator.h b/net/batman-adv/originator.h
index 0e0a12e600af..08e4bcf454c6 100644
--- a/net/batman-adv/originator.h
+++ b/net/batman-adv/originator.h
@@ -86,8 +86,13 @@ batadv_orig_node_vlan_get(struct batadv_orig_node *orig_node,
unsigned short vid);
void batadv_orig_node_vlan_put(struct batadv_orig_node_vlan *orig_vlan);
-/* hashfunction to choose an entry in a hash table of given size
- * hash algorithm from http://en.wikipedia.org/wiki/Hash_table
+/**
+ * batadv_choose_orig() - Return the index of the orig entry in the hash table
+ * @data: mac address of the originator node
+ * @size: the size of the hash table
+ *
+ * Return: the hash index where the object represented by @data should be
+ * stored at.
*/
static inline u32 batadv_choose_orig(const void *data, u32 size)
{
--
2.11.0
^ permalink raw reply related
* [PATCH 18/20] batman-adv: Add kernel-doc to enums in headers
From: Simon Wunderlich @ 2017-12-15 11:43 UTC (permalink / raw)
To: davem; +Cc: netdev, b.a.t.m.a.n, Sven Eckelmann, Simon Wunderlich
In-Reply-To: <20171215114320.13645-1-sw@simonwunderlich.de>
From: Sven Eckelmann <sven@narfation.org>
All enums in types.h are already documented. But some other headers
still have private enums which also should be documented.
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
---
net/batman-adv/hard-interface.h | 23 +++++++++++++++++++++++
net/batman-adv/main.h | 32 ++++++++++++++++++++++++++++++++
2 files changed, 55 insertions(+)
diff --git a/net/batman-adv/hard-interface.h b/net/batman-adv/hard-interface.h
index d90d9cfa7a7a..f29974b487cc 100644
--- a/net/batman-adv/hard-interface.h
+++ b/net/batman-adv/hard-interface.h
@@ -33,12 +33,35 @@
struct net_device;
struct net;
+/**
+ * enum batadv_hard_if_state - State of a hard interface
+ */
enum batadv_hard_if_state {
+ /**
+ * @BATADV_IF_NOT_IN_USE: interface is not used as slave interface of a
+ * batman-adv soft interface
+ */
BATADV_IF_NOT_IN_USE,
+
+ /**
+ * @BATADV_IF_TO_BE_REMOVED: interface will be removed from soft
+ * interface
+ */
BATADV_IF_TO_BE_REMOVED,
+
+ /** @BATADV_IF_INACTIVE: interface is deactivated */
BATADV_IF_INACTIVE,
+
+ /** @BATADV_IF_ACTIVE: interface is used */
BATADV_IF_ACTIVE,
+
+ /** @BATADV_IF_TO_BE_ACTIVATED: interface is getting activated */
BATADV_IF_TO_BE_ACTIVATED,
+
+ /**
+ * @BATADV_IF_I_WANT_YOU: interface is queued up (using sysfs) for being
+ * added as slave interface of a batman-adv soft interface
+ */
BATADV_IF_I_WANT_YOU,
};
diff --git a/net/batman-adv/main.h b/net/batman-adv/main.h
index 63b3ee0bbc40..53f386bedd3b 100644
--- a/net/batman-adv/main.h
+++ b/net/batman-adv/main.h
@@ -143,24 +143,56 @@
*/
#define BATADV_TP_MAX_NUM 5
+/**
+ * enum batadv_mesh_state - State of a soft interface
+ */
enum batadv_mesh_state {
+ /** @BATADV_MESH_INACTIVE: soft interface is not yet running */
BATADV_MESH_INACTIVE,
+
+ /** @BATADV_MESH_ACTIVE: interface is up and running */
BATADV_MESH_ACTIVE,
+
+ /** @BATADV_MESH_DEACTIVATING: interface is getting shut down */
BATADV_MESH_DEACTIVATING,
};
#define BATADV_BCAST_QUEUE_LEN 256
#define BATADV_BATMAN_QUEUE_LEN 256
+/**
+ * enum batadv_uev_action - action type of uevent
+ */
enum batadv_uev_action {
+ /** @BATADV_UEV_ADD: gateway was selected (after none was selected) */
BATADV_UEV_ADD = 0,
+
+ /**
+ * @BATADV_UEV_DEL: selected gateway was removed and none is selected
+ * anymore
+ */
BATADV_UEV_DEL,
+
+ /**
+ * @BATADV_UEV_CHANGE: a different gateway was selected as based gateway
+ */
BATADV_UEV_CHANGE,
+
+ /**
+ * @BATADV_UEV_LOOPDETECT: loop was detected which cannot be handled by
+ * bridge loop avoidance
+ */
BATADV_UEV_LOOPDETECT,
};
+/**
+ * enum batadv_uev_type - Type of uevent
+ */
enum batadv_uev_type {
+ /** @BATADV_UEV_GW: selected gateway was modified */
BATADV_UEV_GW = 0,
+
+ /** @BATADV_UEV_BLA: bridge loop avoidance event */
BATADV_UEV_BLA,
};
--
2.11.0
^ permalink raw reply related
* [PATCH 20/20] batman-adv: Add kernel-doc to externally visible functions
From: Simon Wunderlich @ 2017-12-15 11:43 UTC (permalink / raw)
To: davem; +Cc: netdev, b.a.t.m.a.n, Sven Eckelmann, Simon Wunderlich
In-Reply-To: <20171215114320.13645-1-sw@simonwunderlich.de>
From: Sven Eckelmann <sven@narfation.org>
According to the kernel-doc documentation, externally visible functions
should be documented. This refers to all all non-static function which can
(and will) be used by functions in other sources files.
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
---
net/batman-adv/bat_algo.c | 27 ++++++++++++++++++++++++
net/batman-adv/bat_iv_ogm.c | 5 +++++
net/batman-adv/debugfs.c | 16 ++++++++++++++
net/batman-adv/gateway_client.c | 38 +++++++++++++++++++++++++++++++++
net/batman-adv/gateway_common.c | 9 ++++++++
net/batman-adv/hard-interface.c | 36 ++++++++++++++++++++++++++++++-
net/batman-adv/hash.c | 17 +++++++++++++--
net/batman-adv/icmp_socket.c | 9 ++++++++
net/batman-adv/log.c | 17 +++++++++++++++
net/batman-adv/main.c | 31 +++++++++++++++++++++++++++
net/batman-adv/originator.c | 43 ++++++++++++++++++++++++++++++++++++++
net/batman-adv/routing.c | 29 +++++++++++++++++++++++++
net/batman-adv/send.c | 18 ++++++++++++++++
net/batman-adv/soft-interface.c | 20 ++++++++++++++++++
net/batman-adv/sysfs.c | 32 ++++++++++++++++++++++++++++
net/batman-adv/translation-table.c | 37 ++++++++++++++++++++++++++++++++
16 files changed, 381 insertions(+), 3 deletions(-)
diff --git a/net/batman-adv/bat_algo.c b/net/batman-adv/bat_algo.c
index 06139233bb54..37390a21e5e9 100644
--- a/net/batman-adv/bat_algo.c
+++ b/net/batman-adv/bat_algo.c
@@ -63,6 +63,12 @@ static struct batadv_algo_ops *batadv_algo_get(char *name)
return bat_algo_ops;
}
+/**
+ * batadv_algo_register() - Register callbacks for a mesh algorithm
+ * @bat_algo_ops: mesh algorithm callbacks to add
+ *
+ * Return: 0 on success or negative error number in case of failure
+ */
int batadv_algo_register(struct batadv_algo_ops *bat_algo_ops)
{
struct batadv_algo_ops *bat_algo_ops_tmp;
@@ -92,6 +98,19 @@ int batadv_algo_register(struct batadv_algo_ops *bat_algo_ops)
return 0;
}
+/**
+ * batadv_algo_select() - Select algorithm of soft interface
+ * @bat_priv: the bat priv with all the soft interface information
+ * @name: name of the algorithm to select
+ *
+ * The algorithm callbacks for the soft interface will be set when the algorithm
+ * with the correct name was found. Any previous selected algorithm will not be
+ * deinitialized and the new selected algorithm will also not be initialized.
+ * It is therefore not allowed to call batadv_algo_select outside the creation
+ * function of the soft interface.
+ *
+ * Return: 0 on success or negative error number in case of failure
+ */
int batadv_algo_select(struct batadv_priv *bat_priv, char *name)
{
struct batadv_algo_ops *bat_algo_ops;
@@ -106,6 +125,14 @@ int batadv_algo_select(struct batadv_priv *bat_priv, char *name)
}
#ifdef CONFIG_BATMAN_ADV_DEBUGFS
+
+/**
+ * batadv_algo_seq_print_text() - Print the supported algorithms in a seq file
+ * @seq: seq file to print on
+ * @offset: not used
+ *
+ * Return: always 0
+ */
int batadv_algo_seq_print_text(struct seq_file *seq, void *offset)
{
struct batadv_algo_ops *bat_algo_ops;
diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
index b65cd2366e60..4055338de7f0 100644
--- a/net/batman-adv/bat_iv_ogm.c
+++ b/net/batman-adv/bat_iv_ogm.c
@@ -2855,6 +2855,11 @@ static struct batadv_algo_ops batadv_batman_iv __read_mostly = {
},
};
+/**
+ * batadv_iv_init() - B.A.T.M.A.N. IV initialization function
+ *
+ * Return: 0 on success or negative error number in case of failure
+ */
int __init batadv_iv_init(void)
{
int ret;
diff --git a/net/batman-adv/debugfs.c b/net/batman-adv/debugfs.c
index a36c5ad90912..f179172dd051 100644
--- a/net/batman-adv/debugfs.c
+++ b/net/batman-adv/debugfs.c
@@ -261,6 +261,9 @@ static struct batadv_debuginfo *batadv_hardif_debuginfos[] = {
NULL,
};
+/**
+ * batadv_debugfs_init() - Initialize soft interface independent debugfs entries
+ */
void batadv_debugfs_init(void)
{
struct batadv_debuginfo **bat_debug;
@@ -291,6 +294,9 @@ void batadv_debugfs_init(void)
batadv_debugfs = NULL;
}
+/**
+ * batadv_debugfs_destroy() - Remove all debugfs entries
+ */
void batadv_debugfs_destroy(void)
{
debugfs_remove_recursive(batadv_debugfs);
@@ -357,6 +363,12 @@ void batadv_debugfs_del_hardif(struct batadv_hard_iface *hard_iface)
}
}
+/**
+ * batadv_debugfs_add_meshif() - Initialize interface dependent debugfs entries
+ * @dev: netdev struct of the soft interface
+ *
+ * Return: 0 on success or negative error number in case of failure
+ */
int batadv_debugfs_add_meshif(struct net_device *dev)
{
struct batadv_priv *bat_priv = netdev_priv(dev);
@@ -403,6 +415,10 @@ int batadv_debugfs_add_meshif(struct net_device *dev)
return -ENOMEM;
}
+/**
+ * batadv_debugfs_del_meshif() - Remove interface dependent debugfs entries
+ * @dev: netdev struct of the soft interface
+ */
void batadv_debugfs_del_meshif(struct net_device *dev)
{
struct batadv_priv *bat_priv = netdev_priv(dev);
diff --git a/net/batman-adv/gateway_client.c b/net/batman-adv/gateway_client.c
index 9390da029868..5e2d00731e9f 100644
--- a/net/batman-adv/gateway_client.c
+++ b/net/batman-adv/gateway_client.c
@@ -95,6 +95,12 @@ void batadv_gw_node_put(struct batadv_gw_node *gw_node)
kref_put(&gw_node->refcount, batadv_gw_node_release);
}
+/**
+ * batadv_gw_get_selected_gw_node() - Get currently selected gateway
+ * @bat_priv: the bat priv with all the soft interface information
+ *
+ * Return: selected gateway (with increased refcnt), NULL on errors
+ */
struct batadv_gw_node *
batadv_gw_get_selected_gw_node(struct batadv_priv *bat_priv)
{
@@ -113,6 +119,12 @@ batadv_gw_get_selected_gw_node(struct batadv_priv *bat_priv)
return gw_node;
}
+/**
+ * batadv_gw_get_selected_orig() - Get originator of currently selected gateway
+ * @bat_priv: the bat priv with all the soft interface information
+ *
+ * Return: orig_node of selected gateway (with increased refcnt), NULL on errors
+ */
struct batadv_orig_node *
batadv_gw_get_selected_orig(struct batadv_priv *bat_priv)
{
@@ -206,6 +218,10 @@ void batadv_gw_check_client_stop(struct batadv_priv *bat_priv)
batadv_gw_node_put(curr_gw);
}
+/**
+ * batadv_gw_election() - Elect the best gateway
+ * @bat_priv: the bat priv with all the soft interface information
+ */
void batadv_gw_election(struct batadv_priv *bat_priv)
{
struct batadv_gw_node *curr_gw = NULL;
@@ -294,6 +310,11 @@ void batadv_gw_election(struct batadv_priv *bat_priv)
batadv_neigh_ifinfo_put(router_ifinfo);
}
+/**
+ * batadv_gw_check_election() - Elect orig node as best gateway when eligible
+ * @bat_priv: the bat priv with all the soft interface information
+ * @orig_node: orig node which is to be checked
+ */
void batadv_gw_check_election(struct batadv_priv *bat_priv,
struct batadv_orig_node *orig_node)
{
@@ -462,6 +483,11 @@ void batadv_gw_node_update(struct batadv_priv *bat_priv,
batadv_gw_node_put(gw_node);
}
+/**
+ * batadv_gw_node_delete() - Remove orig_node from gateway list
+ * @bat_priv: the bat priv with all the soft interface information
+ * @orig_node: orig node which is currently in process of being removed
+ */
void batadv_gw_node_delete(struct batadv_priv *bat_priv,
struct batadv_orig_node *orig_node)
{
@@ -473,6 +499,10 @@ void batadv_gw_node_delete(struct batadv_priv *bat_priv,
batadv_gw_node_update(bat_priv, orig_node, &gateway);
}
+/**
+ * batadv_gw_node_free() - Free gateway information from soft interface
+ * @bat_priv: the bat priv with all the soft interface information
+ */
void batadv_gw_node_free(struct batadv_priv *bat_priv)
{
struct batadv_gw_node *gw_node;
@@ -488,6 +518,14 @@ void batadv_gw_node_free(struct batadv_priv *bat_priv)
}
#ifdef CONFIG_BATMAN_ADV_DEBUGFS
+
+/**
+ * batadv_gw_client_seq_print_text() - Print the gateway table in a seq file
+ * @seq: seq file to print on
+ * @offset: not used
+ *
+ * Return: always 0
+ */
int batadv_gw_client_seq_print_text(struct seq_file *seq, void *offset)
{
struct net_device *net_dev = (struct net_device *)seq->private;
diff --git a/net/batman-adv/gateway_common.c b/net/batman-adv/gateway_common.c
index e2d3a8a4df43..d918a176fa7b 100644
--- a/net/batman-adv/gateway_common.c
+++ b/net/batman-adv/gateway_common.c
@@ -167,6 +167,15 @@ void batadv_gw_tvlv_container_update(struct batadv_priv *bat_priv)
}
}
+/**
+ * batadv_gw_bandwidth_set() - Parse and set download/upload gateway bandwidth
+ * from supplied string buffer
+ * @net_dev: netdev struct of the soft interface
+ * @buff: the buffer containing the user data
+ * @count: number of bytes in the buffer
+ *
+ * Return: 'count' on success or a negative error code in case of failure
+ */
ssize_t batadv_gw_bandwidth_set(struct net_device *net_dev, char *buff,
size_t count)
{
diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c
index 485fd1866d86..f8a1dbc75f42 100644
--- a/net/batman-adv/hard-interface.c
+++ b/net/batman-adv/hard-interface.c
@@ -69,6 +69,12 @@ void batadv_hardif_release(struct kref *ref)
kfree_rcu(hard_iface, rcu);
}
+/**
+ * batadv_hardif_get_by_netdev() - Get hard interface object of a net_device
+ * @net_dev: net_device to search for
+ *
+ * Return: batadv_hard_iface of net_dev (with increased refcnt), NULL on errors
+ */
struct batadv_hard_iface *
batadv_hardif_get_by_netdev(const struct net_device *net_dev)
{
@@ -563,6 +569,13 @@ static void batadv_hardif_recalc_extra_skbroom(struct net_device *soft_iface)
soft_iface->needed_tailroom = lower_tailroom;
}
+/**
+ * batadv_hardif_min_mtu() - Calculate maximum MTU for soft interface
+ * @soft_iface: netdev struct of the soft interface
+ *
+ * Return: MTU for the soft-interface (limited by the minimal MTU of all active
+ * slave interfaces)
+ */
int batadv_hardif_min_mtu(struct net_device *soft_iface)
{
struct batadv_priv *bat_priv = netdev_priv(soft_iface);
@@ -609,7 +622,11 @@ int batadv_hardif_min_mtu(struct net_device *soft_iface)
return min_t(int, min_mtu - batadv_max_header_len(), ETH_DATA_LEN);
}
-/* adjusts the MTU if a new interface with a smaller MTU appeared. */
+/**
+ * batadv_update_min_mtu() - Adjusts the MTU if a new interface with a smaller
+ * MTU appeared
+ * @soft_iface: netdev struct of the soft interface
+ */
void batadv_update_min_mtu(struct net_device *soft_iface)
{
soft_iface->mtu = batadv_hardif_min_mtu(soft_iface);
@@ -694,6 +711,14 @@ static int batadv_master_del_slave(struct batadv_hard_iface *slave,
return ret;
}
+/**
+ * batadv_hardif_enable_interface() - Enslave hard interface to soft interface
+ * @hard_iface: hard interface to add to soft interface
+ * @net: the applicable net namespace
+ * @iface_name: name of the soft interface
+ *
+ * Return: 0 on success or negative error number in case of failure
+ */
int batadv_hardif_enable_interface(struct batadv_hard_iface *hard_iface,
struct net *net, const char *iface_name)
{
@@ -805,6 +830,12 @@ int batadv_hardif_enable_interface(struct batadv_hard_iface *hard_iface,
return ret;
}
+/**
+ * batadv_hardif_disable_interface() - Remove hard interface from soft interface
+ * @hard_iface: hard interface to be removed
+ * @autodel: whether to delete soft interface when it doesn't contain any other
+ * slave interfaces
+ */
void batadv_hardif_disable_interface(struct batadv_hard_iface *hard_iface,
enum batadv_hard_if_cleanup autodel)
{
@@ -939,6 +970,9 @@ static void batadv_hardif_remove_interface(struct batadv_hard_iface *hard_iface)
batadv_hardif_put(hard_iface);
}
+/**
+ * batadv_hardif_remove_interfaces() - Remove all hard interfaces
+ */
void batadv_hardif_remove_interfaces(void)
{
struct batadv_hard_iface *hard_iface, *hard_iface_tmp;
diff --git a/net/batman-adv/hash.c b/net/batman-adv/hash.c
index 0569ee47684f..c5fc0555bc4a 100644
--- a/net/batman-adv/hash.c
+++ b/net/batman-adv/hash.c
@@ -36,7 +36,10 @@ static void batadv_hash_init(struct batadv_hashtable *hash)
}
}
-/* free only the hashtable and the hash itself. */
+/**
+ * batadv_hash_destroy() - Free only the hashtable and the hash itself
+ * @hash: hash object to destroy
+ */
void batadv_hash_destroy(struct batadv_hashtable *hash)
{
kfree(hash->list_locks);
@@ -44,7 +47,12 @@ void batadv_hash_destroy(struct batadv_hashtable *hash)
kfree(hash);
}
-/* allocates and clears the hash */
+/**
+ * batadv_hash_new() - Allocates and clears the hashtable
+ * @size: number of hash buckets to allocate
+ *
+ * Return: newly allocated hashtable, NULL on errors
+ */
struct batadv_hashtable *batadv_hash_new(u32 size)
{
struct batadv_hashtable *hash;
@@ -73,6 +81,11 @@ struct batadv_hashtable *batadv_hash_new(u32 size)
return NULL;
}
+/**
+ * batadv_hash_set_lock_class() - Set specific lockdep class for hash spinlocks
+ * @hash: hash object to modify
+ * @key: lockdep class key address
+ */
void batadv_hash_set_lock_class(struct batadv_hashtable *hash,
struct lock_class_key *key)
{
diff --git a/net/batman-adv/icmp_socket.c b/net/batman-adv/icmp_socket.c
index 49467746542a..7bac7b4ee165 100644
--- a/net/batman-adv/icmp_socket.c
+++ b/net/batman-adv/icmp_socket.c
@@ -59,6 +59,9 @@ static void batadv_socket_add_packet(struct batadv_socket_client *socket_client,
struct batadv_icmp_header *icmph,
size_t icmp_len);
+/**
+ * batadv_socket_init() - Initialize soft interface independent socket data
+ */
void batadv_socket_init(void)
{
memset(batadv_socket_client_hash, 0, sizeof(batadv_socket_client_hash));
@@ -318,6 +321,12 @@ static const struct file_operations batadv_fops = {
.llseek = no_llseek,
};
+/**
+ * batadv_socket_setup() - Create debugfs "socket" file
+ * @bat_priv: the bat priv with all the soft interface information
+ *
+ * Return: 0 on success or negative error number in case of failure
+ */
int batadv_socket_setup(struct batadv_priv *bat_priv)
{
struct dentry *d;
diff --git a/net/batman-adv/log.c b/net/batman-adv/log.c
index 59a1eb138e6a..caf24795ec9b 100644
--- a/net/batman-adv/log.c
+++ b/net/batman-adv/log.c
@@ -90,6 +90,13 @@ static int batadv_fdebug_log(struct batadv_priv_debug_log *debug_log,
return 0;
}
+/**
+ * batadv_debug_log() - Add debug log entry
+ * @bat_priv: the bat priv with all the soft interface information
+ * @fmt: format string
+ *
+ * Return: 0 on success or negative error number in case of failure
+ */
int batadv_debug_log(struct batadv_priv *bat_priv, const char *fmt, ...)
{
va_list args;
@@ -201,6 +208,12 @@ static const struct file_operations batadv_log_fops = {
.llseek = no_llseek,
};
+/**
+ * batadv_debug_log_setup() - Initialize debug log
+ * @bat_priv: the bat priv with all the soft interface information
+ *
+ * Return: 0 on success or negative error number in case of failure
+ */
int batadv_debug_log_setup(struct batadv_priv *bat_priv)
{
struct dentry *d;
@@ -226,6 +239,10 @@ int batadv_debug_log_setup(struct batadv_priv *bat_priv)
return -ENOMEM;
}
+/**
+ * batadv_debug_log_cleanup() - Destroy debug log
+ * @bat_priv: the bat priv with all the soft interface information
+ */
void batadv_debug_log_cleanup(struct batadv_priv *bat_priv)
{
kfree(bat_priv->debug_log);
diff --git a/net/batman-adv/main.c b/net/batman-adv/main.c
index b8fe7305d32a..fc6dcea30238 100644
--- a/net/batman-adv/main.c
+++ b/net/batman-adv/main.c
@@ -142,6 +142,12 @@ static void __exit batadv_exit(void)
batadv_tt_cache_destroy();
}
+/**
+ * batadv_mesh_init() - Initialize soft interface
+ * @soft_iface: netdev struct of the soft interface
+ *
+ * Return: 0 on success or negative error number in case of failure
+ */
int batadv_mesh_init(struct net_device *soft_iface)
{
struct batadv_priv *bat_priv = netdev_priv(soft_iface);
@@ -219,6 +225,10 @@ int batadv_mesh_init(struct net_device *soft_iface)
return ret;
}
+/**
+ * batadv_mesh_free() - Deinitialize soft interface
+ * @soft_iface: netdev struct of the soft interface
+ */
void batadv_mesh_free(struct net_device *soft_iface)
{
struct batadv_priv *bat_priv = netdev_priv(soft_iface);
@@ -415,6 +425,16 @@ static int batadv_recv_unhandled_packet(struct sk_buff *skb,
/* incoming packets with the batman ethertype received on any active hard
* interface
*/
+
+/**
+ * batadv_batman_skb_recv() - Handle incoming message from an hard interface
+ * @skb: the received packet
+ * @dev: the net device that the packet was received on
+ * @ptype: packet type of incoming packet (ETH_P_BATMAN)
+ * @orig_dev: the original receive net device (e.g. bonded device)
+ *
+ * Return: NET_RX_SUCCESS on success or NET_RX_DROP in case of failure
+ */
int batadv_batman_skb_recv(struct sk_buff *skb, struct net_device *dev,
struct packet_type *ptype,
struct net_device *orig_dev)
@@ -538,6 +558,13 @@ static void batadv_recv_handler_init(void)
batadv_rx_handler[BATADV_UNICAST_FRAG] = batadv_recv_frag_packet;
}
+/**
+ * batadv_recv_handler_register() - Register handler for batman-adv packet type
+ * @packet_type: batadv_packettype which should be handled
+ * @recv_handler: receive handler for the packet type
+ *
+ * Return: 0 on success or negative error number in case of failure
+ */
int
batadv_recv_handler_register(u8 packet_type,
int (*recv_handler)(struct sk_buff *,
@@ -555,6 +582,10 @@ batadv_recv_handler_register(u8 packet_type,
return 0;
}
+/**
+ * batadv_recv_handler_unregister() - Unregister handler for packet type
+ * @packet_type: batadv_packettype which should no longer be handled
+ */
void batadv_recv_handler_unregister(u8 packet_type)
{
batadv_rx_handler[packet_type] = batadv_recv_unhandled_packet;
diff --git a/net/batman-adv/originator.c b/net/batman-adv/originator.c
index 1e3f9a34df90..dafc73811aa6 100644
--- a/net/batman-adv/originator.c
+++ b/net/batman-adv/originator.c
@@ -60,6 +60,13 @@
/* hash class keys */
static struct lock_class_key batadv_orig_hash_lock_class_key;
+/**
+ * batadv_orig_hash_find() - Find and return originator from orig_hash
+ * @bat_priv: the bat priv with all the soft interface information
+ * @data: mac address of the originator
+ *
+ * Return: orig_node (with increased refcnt), NULL on errors
+ */
struct batadv_orig_node *
batadv_orig_hash_find(struct batadv_priv *bat_priv, const void *data)
{
@@ -203,6 +210,12 @@ void batadv_orig_node_vlan_put(struct batadv_orig_node_vlan *orig_vlan)
kref_put(&orig_vlan->refcount, batadv_orig_node_vlan_release);
}
+/**
+ * batadv_originator_init() - Initialize all originator structures
+ * @bat_priv: the bat priv with all the soft interface information
+ *
+ * Return: 0 on success or negative error number in case of failure
+ */
int batadv_originator_init(struct batadv_priv *bat_priv)
{
if (bat_priv->orig_hash)
@@ -961,6 +974,10 @@ void batadv_orig_node_put(struct batadv_orig_node *orig_node)
kref_put(&orig_node->refcount, batadv_orig_node_release);
}
+/**
+ * batadv_originator_free() - Free all originator structures
+ * @bat_priv: the bat priv with all the soft interface information
+ */
void batadv_originator_free(struct batadv_priv *bat_priv)
{
struct batadv_hashtable *hash = bat_priv->orig_hash;
@@ -1376,12 +1393,24 @@ static void batadv_purge_orig(struct work_struct *work)
msecs_to_jiffies(BATADV_ORIG_WORK_PERIOD));
}
+/**
+ * batadv_purge_orig_ref() - Purge all outdated originators
+ * @bat_priv: the bat priv with all the soft interface information
+ */
void batadv_purge_orig_ref(struct batadv_priv *bat_priv)
{
_batadv_purge_orig(bat_priv);
}
#ifdef CONFIG_BATMAN_ADV_DEBUGFS
+
+/**
+ * batadv_orig_seq_print_text() - Print the originator table in a seq file
+ * @seq: seq file to print on
+ * @offset: not used
+ *
+ * Return: always 0
+ */
int batadv_orig_seq_print_text(struct seq_file *seq, void *offset)
{
struct net_device *net_dev = (struct net_device *)seq->private;
@@ -1534,6 +1563,13 @@ int batadv_orig_dump(struct sk_buff *msg, struct netlink_callback *cb)
return ret;
}
+/**
+ * batadv_orig_hash_add_if() - Add interface to originators in orig_hash
+ * @hard_iface: hard interface to add (already slave of the soft interface)
+ * @max_if_num: new number of interfaces
+ *
+ * Return: 0 on success or negative error number in case of failure
+ */
int batadv_orig_hash_add_if(struct batadv_hard_iface *hard_iface,
int max_if_num)
{
@@ -1569,6 +1605,13 @@ int batadv_orig_hash_add_if(struct batadv_hard_iface *hard_iface,
return -ENOMEM;
}
+/**
+ * batadv_orig_hash_del_if() - Remove interface from originators in orig_hash
+ * @hard_iface: hard interface to remove (still slave of the soft interface)
+ * @max_if_num: new number of interfaces
+ *
+ * Return: 0 on success or negative error number in case of failure
+ */
int batadv_orig_hash_del_if(struct batadv_hard_iface *hard_iface,
int max_if_num)
{
diff --git a/net/batman-adv/routing.c b/net/batman-adv/routing.c
index 12954e746c5e..36001738917b 100644
--- a/net/batman-adv/routing.c
+++ b/net/batman-adv/routing.c
@@ -183,6 +183,14 @@ bool batadv_window_protected(struct batadv_priv *bat_priv, s32 seq_num_diff,
return false;
}
+/**
+ * batadv_check_management_packet() - Check preconditions for management packets
+ * @skb: incoming packet buffer
+ * @hard_iface: incoming hard interface
+ * @header_len: minimal header length of packet type
+ *
+ * Return: true when management preconditions are met, false otherwise
+ */
bool batadv_check_management_packet(struct sk_buff *skb,
struct batadv_hard_iface *hard_iface,
int header_len)
@@ -350,6 +358,13 @@ static int batadv_recv_icmp_ttl_exceeded(struct batadv_priv *bat_priv,
return ret;
}
+/**
+ * batadv_recv_icmp_packet() - Process incoming icmp packet
+ * @skb: incoming packet buffer
+ * @recv_if: incoming hard interface
+ *
+ * Return: NET_RX_SUCCESS on success or NET_RX_DROP in case of failure
+ */
int batadv_recv_icmp_packet(struct sk_buff *skb,
struct batadv_hard_iface *recv_if)
{
@@ -938,6 +953,13 @@ int batadv_recv_unhandled_unicast_packet(struct sk_buff *skb,
return NET_RX_DROP;
}
+/**
+ * batadv_recv_unicast_packet() - Process incoming unicast packet
+ * @skb: incoming packet buffer
+ * @recv_if: incoming hard interface
+ *
+ * Return: NET_RX_SUCCESS on success or NET_RX_DROP in case of failure
+ */
int batadv_recv_unicast_packet(struct sk_buff *skb,
struct batadv_hard_iface *recv_if)
{
@@ -1158,6 +1180,13 @@ int batadv_recv_frag_packet(struct sk_buff *skb,
return ret;
}
+/**
+ * batadv_recv_bcast_packet() - Process incoming broadcast packet
+ * @skb: incoming packet buffer
+ * @recv_if: incoming hard interface
+ *
+ * Return: NET_RX_SUCCESS on success or NET_RX_DROP in case of failure
+ */
int batadv_recv_bcast_packet(struct sk_buff *skb,
struct batadv_hard_iface *recv_if)
{
diff --git a/net/batman-adv/send.c b/net/batman-adv/send.c
index 68705584f537..c9bb6e17e31c 100644
--- a/net/batman-adv/send.c
+++ b/net/batman-adv/send.c
@@ -126,12 +126,30 @@ int batadv_send_skb_packet(struct sk_buff *skb,
return NET_XMIT_DROP;
}
+/**
+ * batadv_send_broadcast_skb() - Send broadcast packet via hard interface
+ * @skb: packet to be transmitted (with batadv header and no outer eth header)
+ * @hard_iface: outgoing interface
+ *
+ * Return: A negative errno code is returned on a failure. A success does not
+ * guarantee the frame will be transmitted as it may be dropped due
+ * to congestion or traffic shaping.
+ */
int batadv_send_broadcast_skb(struct sk_buff *skb,
struct batadv_hard_iface *hard_iface)
{
return batadv_send_skb_packet(skb, hard_iface, batadv_broadcast_addr);
}
+/**
+ * batadv_send_unicast_skb() - Send unicast packet to neighbor
+ * @skb: packet to be transmitted (with batadv header and no outer eth header)
+ * @neigh: neighbor which is used as next hop to destination
+ *
+ * Return: A negative errno code is returned on a failure. A success does not
+ * guarantee the frame will be transmitted as it may be dropped due
+ * to congestion or traffic shaping.
+ */
int batadv_send_unicast_skb(struct sk_buff *skb,
struct batadv_neigh_node *neigh)
{
diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
index e2d5c2ae640b..64d82e90d23c 100644
--- a/net/batman-adv/soft-interface.c
+++ b/net/batman-adv/soft-interface.c
@@ -67,6 +67,13 @@
#include "sysfs.h"
#include "translation-table.h"
+/**
+ * batadv_skb_head_push() - Increase header size and move (push) head pointer
+ * @skb: packet buffer which should be modified
+ * @len: number of bytes to add
+ *
+ * Return: 0 on success or negative error number in case of failure
+ */
int batadv_skb_head_push(struct sk_buff *skb, unsigned int len)
{
int result;
@@ -1066,6 +1073,13 @@ static void batadv_softif_init_early(struct net_device *dev)
dev->ethtool_ops = &batadv_ethtool_ops;
}
+/**
+ * batadv_softif_create() - Create and register soft interface
+ * @net: the applicable net namespace
+ * @name: name of the new soft interface
+ *
+ * Return: newly allocated soft_interface, NULL on errors
+ */
struct net_device *batadv_softif_create(struct net *net, const char *name)
{
struct net_device *soft_iface;
@@ -1143,6 +1157,12 @@ static void batadv_softif_destroy_netlink(struct net_device *soft_iface,
unregister_netdevice_queue(soft_iface, head);
}
+/**
+ * batadv_softif_is_valid() - Check whether device is a batadv soft interface
+ * @net_dev: device which should be checked
+ *
+ * Return: true when net_dev is a batman-adv interface, false otherwise
+ */
bool batadv_softif_is_valid(const struct net_device *net_dev)
{
if (net_dev->netdev_ops->ndo_start_xmit == batadv_interface_tx)
diff --git a/net/batman-adv/sysfs.c b/net/batman-adv/sysfs.c
index 61ab133aeeb1..eebd3d1ebfd7 100644
--- a/net/batman-adv/sysfs.c
+++ b/net/batman-adv/sysfs.c
@@ -737,6 +737,12 @@ static struct batadv_attribute *batadv_vlan_attrs[] = {
NULL,
};
+/**
+ * batadv_sysfs_add_meshif() - Add soft interface specific sysfs entries
+ * @dev: netdev struct of the soft interface
+ *
+ * Return: 0 on success or negative error number in case of failure
+ */
int batadv_sysfs_add_meshif(struct net_device *dev)
{
struct kobject *batif_kobject = &dev->dev.kobj;
@@ -777,6 +783,10 @@ int batadv_sysfs_add_meshif(struct net_device *dev)
return -ENOMEM;
}
+/**
+ * batadv_sysfs_del_meshif() - Remove soft interface specific sysfs entries
+ * @dev: netdev struct of the soft interface
+ */
void batadv_sysfs_del_meshif(struct net_device *dev)
{
struct batadv_priv *bat_priv = netdev_priv(dev);
@@ -1134,6 +1144,13 @@ static struct batadv_attribute *batadv_batman_attrs[] = {
NULL,
};
+/**
+ * batadv_sysfs_add_hardif() - Add hard interface specific sysfs entries
+ * @hardif_obj: address where to store the pointer to new sysfs folder
+ * @dev: netdev struct of the hard interface
+ *
+ * Return: 0 on success or negative error number in case of failure
+ */
int batadv_sysfs_add_hardif(struct kobject **hardif_obj, struct net_device *dev)
{
struct kobject *hardif_kobject = &dev->dev.kobj;
@@ -1168,6 +1185,11 @@ int batadv_sysfs_add_hardif(struct kobject **hardif_obj, struct net_device *dev)
return -ENOMEM;
}
+/**
+ * batadv_sysfs_del_hardif() - Remove hard interface specific sysfs entries
+ * @hardif_obj: address to the pointer to which stores batman-adv sysfs folder
+ * of the hard interface
+ */
void batadv_sysfs_del_hardif(struct kobject **hardif_obj)
{
kobject_uevent(*hardif_obj, KOBJ_REMOVE);
@@ -1176,6 +1198,16 @@ void batadv_sysfs_del_hardif(struct kobject **hardif_obj)
*hardif_obj = NULL;
}
+/**
+ * batadv_throw_uevent() - Send an uevent with batman-adv specific env data
+ * @bat_priv: the bat priv with all the soft interface information
+ * @type: subsystem type of event. Stored in uevent's BATTYPE
+ * @action: action type of event. Stored in uevent's BATACTION
+ * @data: string with additional information to the event (ignored for
+ * BATADV_UEV_DEL). Stored in uevent's BATDATA
+ *
+ * Return: 0 on success or negative error number in case of failure
+ */
int batadv_throw_uevent(struct batadv_priv *bat_priv, enum batadv_uev_type type,
enum batadv_uev_action action, const char *data)
{
diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
index 8bcc459543ac..5d3ba12002df 100644
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c
@@ -1057,6 +1057,14 @@ static void batadv_tt_tvlv_container_update(struct batadv_priv *bat_priv)
}
#ifdef CONFIG_BATMAN_ADV_DEBUGFS
+
+/**
+ * batadv_tt_local_seq_print_text() - Print the local tt table in a seq file
+ * @seq: seq file to print on
+ * @offset: not used
+ *
+ * Return: always 0
+ */
int batadv_tt_local_seq_print_text(struct seq_file *seq, void *offset)
{
struct net_device *net_dev = (struct net_device *)seq->private;
@@ -1929,6 +1937,13 @@ batadv_tt_global_print_entry(struct batadv_priv *bat_priv,
}
}
+/**
+ * batadv_tt_global_seq_print_text() - Print the global tt table in a seq file
+ * @seq: seq file to print on
+ * @offset: not used
+ *
+ * Return: always 0
+ */
int batadv_tt_global_seq_print_text(struct seq_file *seq, void *offset)
{
struct net_device *net_dev = (struct net_device *)seq->private;
@@ -3731,6 +3746,10 @@ static void batadv_tt_purge(struct work_struct *work)
msecs_to_jiffies(BATADV_TT_WORK_PERIOD));
}
+/**
+ * batadv_tt_free() - Free translation table of soft interface
+ * @bat_priv: the bat priv with all the soft interface information
+ */
void batadv_tt_free(struct batadv_priv *bat_priv)
{
batadv_tvlv_container_unregister(bat_priv, BATADV_TVLV_TT, 1);
@@ -3878,6 +3897,15 @@ void batadv_tt_local_commit_changes(struct batadv_priv *bat_priv)
spin_unlock_bh(&bat_priv->tt.commit_lock);
}
+/**
+ * batadv_is_ap_isolated() - Check if packet from upper layer should be dropped
+ * @bat_priv: the bat priv with all the soft interface information
+ * @src: source mac address of packet
+ * @dst: destination mac address of packet
+ * @vid: vlan id of packet
+ *
+ * Return: true when src+dst(+vid) pair should be isolated, false otherwise
+ */
bool batadv_is_ap_isolated(struct batadv_priv *bat_priv, u8 *src, u8 *dst,
unsigned short vid)
{
@@ -4049,6 +4077,15 @@ bool batadv_tt_local_client_is_roaming(struct batadv_priv *bat_priv,
return ret;
}
+/**
+ * batadv_tt_add_temporary_global_entry() - Add temporary entry to global TT
+ * @bat_priv: the bat priv with all the soft interface information
+ * @orig_node: orig node which the temporary entry should be associated with
+ * @addr: mac address of the client
+ * @vid: VLAN id of the new temporary global translation table
+ *
+ * Return: true when temporary tt entry could be added, false otherwise
+ */
bool batadv_tt_add_temporary_global_entry(struct batadv_priv *bat_priv,
struct batadv_orig_node *orig_node,
const unsigned char *addr,
--
2.11.0
^ permalink raw reply related
* Re: [B.A.T.M.A.N.] [RFC v2 2/6] batman-adv: Rename batman-adv.h to batadv_genl.h
From: Sven Eckelmann @ 2017-12-15 11:48 UTC (permalink / raw)
To: b.a.t.m.a.n
Cc: Willem de Bruijn, Network Development, Jiri Pirko, LKML,
Eric Dumazet, David S . Miller
In-Reply-To: <2907097.8HHYkPN8Gn@bentobox>
[-- Attachment #1: Type: text/plain, Size: 1223 bytes --]
On Freitag, 15. Dezember 2017 11:32:05 CET Sven Eckelmann wrote:
> On Mittwoch, 6. Dezember 2017 11:58:14 CET Willem de Bruijn wrote:
> [...]
> > >> > ---
> > >> > MAINTAINERS | 2 +-
> > >> > include/uapi/linux/{batman_adv.h => batadv_genl.h} | 6 +++---
> > >>
> > >> This and the previous patch changes uapi. That might break userspace
> > >> applications that rely on it.
> > >
> > > I am not aware of any application because all (alfred, batctl and some gluon
> > > integration) of them currently ship their own copy because distribution didn't
> > > catch up. And this is also the reason why I want to do it now - not later.
> >
> > That assumes that you know all applications, including those not
> > publicly available. It may be true in this instance, but it is not
> > possible to be certain.
>
> I've just talked with Simon. Because you have a problem with these two
> changes, he suggested that I should drop these two patches and merge packet.h
> with the uapi batadv genl header batman_adv.h
No, this is also bad because batman_adv.h is MIT license and packet.h is
GPL-2. So what other name would you suggest for packet.h? batman_adv_packet.h?
Kind regards,
Sven
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply
* Re: [RFT/RFC net-next 0/2] net: dsa: Plug in PHYLINK support
From: Russell King - ARM Linux @ 2017-12-15 12:08 UTC (permalink / raw)
To: Florian Fainelli
Cc: netdev, sean.wang, john, kernel, privat, Woojung.Huh,
vivien.didelot, andrew
In-Reply-To: <20171215002850.27862-1-f.fainelli@gmail.com>
On Thu, Dec 14, 2017 at 04:28:48PM -0800, Florian Fainelli wrote:
> Hi all,
>
> This patch series replaces the existing PHYLIB integration with PHYLINK which
> is a superior solution since we need to support a collection of fixed links,
> integrated PHYs, SFP, non-pluggable SFPs etc.
>
> I am expecting quite a lot of breakage, for a number of reasons:
>
> - PHYLINK does not create a PHY device for fixed links (MLO_AN_FIXED), which
> means that user-facing port (not DSA, not CPU) need to be explicitly handled
> with phylink_mac_ops now
>
> - only been able to test this on a limited number of platforms, and not the
> ZII devel B/C boards yet
>
> Please test and report!
The good news is that it almost works on the ZII Rev C with the SFF
modules, but there's a few issues that need solving:
1. s/WARN_ON(!lockdep_rtnl_is_held())/ASSERT_RTNL()/ in phylink.c -
probably wouldn't have been noticed if it wasn't for the lockdep
splat with DSA's interrupt handling during boot that's been there
since -rc1. (Andrew mentioned that it's known, so I haven't
reported that.)
2. ports without a phy but with sfp cause the "no phy at" and
"failed to connect to port" message - I think we need a way for
DSA to know whether it should be attempting to attach a PHY.
3. We need mv88e6xxx to implement at least phylink_mac_link_state()
so that SFPs report sane ethtool information. It also needs to
implement phylink_mac_config() so that the link can be appropriately
configured to the module's capabilities, and phylink_validate() to
do the jiggery for choosing between 1000base-X vs 2500base-X mode
if the DSA switches can't automatically select the appropriate one.
With a few hacks for the above, I can get TX_DISABLE on the SFF2 module
to follow the interface up/down status, but as I say more work is needed
so that mv88e6xxx works with the phylink callbacks for the SFF modules
to be properly supported.
--
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line in suburbia: sync at 8.8Mbps down 630kbps up
According to speedtest.net: 8.21Mbps down 510kbps up
^ permalink raw reply
* [PATCH 3/5] xfrm: Fix xfrm_replay_overflow_offload_esn
From: Steffen Klassert @ 2017-12-15 12:19 UTC (permalink / raw)
To: David Miller; +Cc: Herbert Xu, Steffen Klassert, netdev
In-Reply-To: <20171215121952.20745-1-steffen.klassert@secunet.com>
From: Yossef Efraim <yossefe@mellanox.com>
In case of wrap around, replay_esn->oseq_hi is not updated
before it is tested for it's actual value, leading function
to fail with overflow indication and packets being dropped.
This patch updates replay_esn->oseq_hi in the right place.
Fixes: d7dbefc45cf5 ("xfrm: Add xfrm_replay_overflow functions for offloading")
Signed-off-by: Yossef Efraim <yossefe@mellanox.com>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
---
net/xfrm/xfrm_replay.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/net/xfrm/xfrm_replay.c b/net/xfrm/xfrm_replay.c
index 8b23c5bcf8e8..02501817227b 100644
--- a/net/xfrm/xfrm_replay.c
+++ b/net/xfrm/xfrm_replay.c
@@ -666,7 +666,7 @@ static int xfrm_replay_overflow_offload_esn(struct xfrm_state *x, struct sk_buff
if (unlikely(oseq < replay_esn->oseq)) {
XFRM_SKB_CB(skb)->seq.output.hi = ++oseq_hi;
xo->seq.hi = oseq_hi;
-
+ replay_esn->oseq_hi = oseq_hi;
if (replay_esn->oseq_hi == 0) {
replay_esn->oseq--;
replay_esn->oseq_hi--;
@@ -678,7 +678,6 @@ static int xfrm_replay_overflow_offload_esn(struct xfrm_state *x, struct sk_buff
}
replay_esn->oseq = oseq;
- replay_esn->oseq_hi = oseq_hi;
if (xfrm_aevent_is_on(net))
x->repl->notify(x, XFRM_REPLAY_UPDATE);
--
2.14.1
^ permalink raw reply related
* [PATCH 4/5] xfrm: Fix xfrm_dev_state_add to fail for unsupported HW SA option
From: Steffen Klassert @ 2017-12-15 12:19 UTC (permalink / raw)
To: David Miller; +Cc: Herbert Xu, Steffen Klassert, netdev
In-Reply-To: <20171215121952.20745-1-steffen.klassert@secunet.com>
From: Yossef Efraim <yossefe@mellanox.com>
xfrm_dev_state_add function returns success for unsupported HW SA options.
Resulting the calling function to create SW SA without corrlating HW SA.
Desipte IPSec device offloading option was chosen.
These not supported HW SA options are hard coded within xfrm_dev_state_add
function.
SW backward compatibility will break if we add any of these option as old
HW will fail with new SW.
This patch changes the behaviour to return -EINVAL in case unsupported
option is chosen.
Notifying user application regarding failure and not breaking backward
compatibility for newly added HW SA options.
Signed-off-by: Yossef Efraim <yossefe@mellanox.com>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
---
net/xfrm/xfrm_device.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/xfrm/xfrm_device.c b/net/xfrm/xfrm_device.c
index 30e5746085b8..dc68d9c1fc8f 100644
--- a/net/xfrm/xfrm_device.c
+++ b/net/xfrm/xfrm_device.c
@@ -67,7 +67,7 @@ int xfrm_dev_state_add(struct net *net, struct xfrm_state *x,
/* We don't yet support UDP encapsulation, TFC padding and ESN. */
if (x->encap || x->tfcpad || (x->props.flags & XFRM_STATE_ESN))
- return 0;
+ return -EINVAL;
dev = dev_get_by_index(net, xuo->ifindex);
if (!dev) {
--
2.14.1
^ permalink raw reply related
* [PATCH 5/5] xfrm: Remove redundant state assignment in xfrm_input()
From: Steffen Klassert @ 2017-12-15 12:19 UTC (permalink / raw)
To: David Miller; +Cc: Herbert Xu, Steffen Klassert, netdev
In-Reply-To: <20171215121952.20745-1-steffen.klassert@secunet.com>
From: Aviv Heller <avivh@mellanox.com>
x is already initialized to the same value, above.
Signed-off-by: Aviv Heller <avivh@mellanox.com>
Signed-off-by: Yevgeny Kliteynik <kliteyn@mellanox.com>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
---
net/xfrm/xfrm_input.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/net/xfrm/xfrm_input.c b/net/xfrm/xfrm_input.c
index 347ab31574d5..ac277b97e0d7 100644
--- a/net/xfrm/xfrm_input.c
+++ b/net/xfrm/xfrm_input.c
@@ -231,7 +231,6 @@ int xfrm_input(struct sk_buff *skb, int nexthdr, __be32 spi, int encap_type)
if (xo && (xo->flags & CRYPTO_DONE)) {
crypto_done = true;
- x = xfrm_input_state(skb);
family = XFRM_SPI_SKB_CB(skb)->family;
if (!(xo->status & CRYPTO_SUCCESS)) {
--
2.14.1
^ permalink raw reply related
* pull request (net-next): ipsec-next 2017-12-15
From: Steffen Klassert @ 2017-12-15 12:19 UTC (permalink / raw)
To: David Miller; +Cc: Herbert Xu, Steffen Klassert, netdev
1) Currently we can add or update socket policies, but
not clear them. Support clearing of socket policies
too. From Lorenzo Colitti.
2) Add documentation for the xfrm device offload api.
From Shannon Nelson.
3) Fix IPsec extended sequence numbers (ESN) for
IPsec offloading. From Yossef Efraim.
4) xfrm_dev_state_add function returns success even for
unsupported options, fix this to fail in such cases.
From Yossef Efraim.
5) Remove a redundant xfrm_state assignment.
From Aviv Heller.
Please pull or let me know if there are problems.
Thanks!
The following changes since commit b9151761021e25c024a6670df4e7c43ffbab0e1d:
Merge tag 'nfsd-4.15-1' of git://linux-nfs.org/~bfields/linux (2017-11-29 14:49:26 -0800)
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/klassert/ipsec-next.git master
for you to fetch changes up to 9b7e14dba0c087e950fc024b486e8f729c1ee672:
xfrm: Remove redundant state assignment in xfrm_input() (2017-12-01 07:41:48 +0100)
----------------------------------------------------------------
Aviv Heller (1):
xfrm: Remove redundant state assignment in xfrm_input()
Lorenzo Colitti (1):
net: xfrm: allow clearing socket xfrm policies.
Shannon Nelson (1):
xfrm: add documentation for xfrm device offload api
Yossef Efraim (2):
xfrm: Fix xfrm_replay_overflow_offload_esn
xfrm: Fix xfrm_dev_state_add to fail for unsupported HW SA option
Documentation/networking/00-INDEX | 2 +
Documentation/networking/xfrm_device.txt | 132 +++++++++++++++++++++++++++++++
net/xfrm/xfrm_device.c | 2 +-
net/xfrm/xfrm_input.c | 1 -
net/xfrm/xfrm_policy.c | 2 +-
net/xfrm/xfrm_replay.c | 3 +-
net/xfrm/xfrm_state.c | 7 ++
7 files changed, 144 insertions(+), 5 deletions(-)
create mode 100644 Documentation/networking/xfrm_device.txt
^ permalink raw reply
* [PATCH 1/5] net: xfrm: allow clearing socket xfrm policies.
From: Steffen Klassert @ 2017-12-15 12:19 UTC (permalink / raw)
To: David Miller; +Cc: Herbert Xu, Steffen Klassert, netdev
In-Reply-To: <20171215121952.20745-1-steffen.klassert@secunet.com>
From: Lorenzo Colitti <lorenzo@google.com>
Currently it is possible to add or update socket policies, but
not clear them. Therefore, once a socket policy has been applied,
the socket cannot be used for unencrypted traffic.
This patch allows (privileged) users to clear socket policies by
passing in a NULL pointer and zero length argument to the
{IP,IPV6}_{IPSEC,XFRM}_POLICY setsockopts. This results in both
the incoming and outgoing policies being cleared.
The simple approach taken in this patch cannot clear socket
policies in only one direction. If desired this could be added
in the future, for example by continuing to pass in a length of
zero (which currently is guaranteed to return EMSGSIZE) and
making the policy be a pointer to an integer that contains one
of the XFRM_POLICY_{IN,OUT} enum values.
An alternative would have been to interpret the length as a
signed integer and use XFRM_POLICY_IN (i.e., 0) to clear the
input policy and -XFRM_POLICY_OUT (i.e., -1) to clear the output
policy.
Tested: https://android-review.googlesource.com/539816
Signed-off-by: Lorenzo Colitti <lorenzo@google.com>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
---
net/xfrm/xfrm_policy.c | 2 +-
net/xfrm/xfrm_state.c | 7 +++++++
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
index 9542975eb2f9..3263662fb20a 100644
--- a/net/xfrm/xfrm_policy.c
+++ b/net/xfrm/xfrm_policy.c
@@ -1251,7 +1251,7 @@ EXPORT_SYMBOL(xfrm_policy_delete);
int xfrm_sk_policy_insert(struct sock *sk, int dir, struct xfrm_policy *pol)
{
- struct net *net = xp_net(pol);
+ struct net *net = sock_net(sk);
struct xfrm_policy *old_pol;
#ifdef CONFIG_XFRM_SUB_POLICY
diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
index 065d89606888..1b7856be3eeb 100644
--- a/net/xfrm/xfrm_state.c
+++ b/net/xfrm/xfrm_state.c
@@ -2048,6 +2048,13 @@ int xfrm_user_policy(struct sock *sk, int optname, u8 __user *optval, int optlen
struct xfrm_mgr *km;
struct xfrm_policy *pol = NULL;
+ if (!optval && !optlen) {
+ xfrm_sk_policy_insert(sk, XFRM_POLICY_IN, NULL);
+ xfrm_sk_policy_insert(sk, XFRM_POLICY_OUT, NULL);
+ __sk_dst_reset(sk);
+ return 0;
+ }
+
if (optlen <= 0 || optlen > PAGE_SIZE)
return -EMSGSIZE;
--
2.14.1
^ permalink raw reply related
* [PATCH 2/5] xfrm: add documentation for xfrm device offload api
From: Steffen Klassert @ 2017-12-15 12:19 UTC (permalink / raw)
To: David Miller; +Cc: Herbert Xu, Steffen Klassert, netdev
In-Reply-To: <20171215121952.20745-1-steffen.klassert@secunet.com>
From: Shannon Nelson <shannon.nelson@oracle.com>
Add a writeup on how to use the XFRM device offload API, and
mention this new file in the index.
Signed-off-by: Shannon Nelson <shannon.nelson@oracle.com>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
---
Documentation/networking/00-INDEX | 2 +
Documentation/networking/xfrm_device.txt | 132 +++++++++++++++++++++++++++++++
2 files changed, 134 insertions(+)
create mode 100644 Documentation/networking/xfrm_device.txt
diff --git a/Documentation/networking/00-INDEX b/Documentation/networking/00-INDEX
index 7a79b3587dd3..f5d642c01dd3 100644
--- a/Documentation/networking/00-INDEX
+++ b/Documentation/networking/00-INDEX
@@ -228,6 +228,8 @@ x25.txt
- general info on X.25 development.
x25-iface.txt
- description of the X.25 Packet Layer to LAPB device interface.
+xfrm_device.txt
+ - description of XFRM offload API
xfrm_proc.txt
- description of the statistics package for XFRM.
xfrm_sync.txt
diff --git a/Documentation/networking/xfrm_device.txt b/Documentation/networking/xfrm_device.txt
new file mode 100644
index 000000000000..2d9d588cd34b
--- /dev/null
+++ b/Documentation/networking/xfrm_device.txt
@@ -0,0 +1,132 @@
+
+===============================================
+XFRM device - offloading the IPsec computations
+===============================================
+Shannon Nelson <shannon.nelson@oracle.com>
+
+
+Overview
+========
+
+IPsec is a useful feature for securing network traffic, but the
+computational cost is high: a 10Gbps link can easily be brought down
+to under 1Gbps, depending on the traffic and link configuration.
+Luckily, there are NICs that offer a hardware based IPsec offload which
+can radically increase throughput and decrease CPU utilization. The XFRM
+Device interface allows NIC drivers to offer to the stack access to the
+hardware offload.
+
+Userland access to the offload is typically through a system such as
+libreswan or KAME/raccoon, but the iproute2 'ip xfrm' command set can
+be handy when experimenting. An example command might look something
+like this:
+
+ ip x s add proto esp dst 14.0.0.70 src 14.0.0.52 spi 0x07 mode transport \
+ reqid 0x07 replay-window 32 \
+ aead 'rfc4106(gcm(aes))' 0x44434241343332312423222114131211f4f3f2f1 128 \
+ sel src 14.0.0.52/24 dst 14.0.0.70/24 proto tcp \
+ offload dev eth4 dir in
+
+Yes, that's ugly, but that's what shell scripts and/or libreswan are for.
+
+
+
+Callbacks to implement
+======================
+
+/* from include/linux/netdevice.h */
+struct xfrmdev_ops {
+ int (*xdo_dev_state_add) (struct xfrm_state *x);
+ void (*xdo_dev_state_delete) (struct xfrm_state *x);
+ void (*xdo_dev_state_free) (struct xfrm_state *x);
+ bool (*xdo_dev_offload_ok) (struct sk_buff *skb,
+ struct xfrm_state *x);
+};
+
+The NIC driver offering ipsec offload will need to implement these
+callbacks to make the offload available to the network stack's
+XFRM subsytem. Additionally, the feature bits NETIF_F_HW_ESP and
+NETIF_F_HW_ESP_TX_CSUM will signal the availability of the offload.
+
+
+
+Flow
+====
+
+At probe time and before the call to register_netdev(), the driver should
+set up local data structures and XFRM callbacks, and set the feature bits.
+The XFRM code's listener will finish the setup on NETDEV_REGISTER.
+
+ adapter->netdev->xfrmdev_ops = &ixgbe_xfrmdev_ops;
+ adapter->netdev->features |= NETIF_F_HW_ESP;
+ adapter->netdev->hw_enc_features |= NETIF_F_HW_ESP;
+
+When new SAs are set up with a request for "offload" feature, the
+driver's xdo_dev_state_add() will be given the new SA to be offloaded
+and an indication of whether it is for Rx or Tx. The driver should
+ - verify the algorithm is supported for offloads
+ - store the SA information (key, salt, target-ip, protocol, etc)
+ - enable the HW offload of the SA
+
+The driver can also set an offload_handle in the SA, an opaque void pointer
+that can be used to convey context into the fast-path offload requests.
+
+ xs->xso.offload_handle = context;
+
+
+When the network stack is preparing an IPsec packet for an SA that has
+been setup for offload, it first calls into xdo_dev_offload_ok() with
+the skb and the intended offload state to ask the driver if the offload
+will serviceable. This can check the packet information to be sure the
+offload can be supported (e.g. IPv4 or IPv6, no IPv4 options, etc) and
+return true of false to signify its support.
+
+When ready to send, the driver needs to inspect the Tx packet for the
+offload information, including the opaque context, and set up the packet
+send accordingly.
+
+ xs = xfrm_input_state(skb);
+ context = xs->xso.offload_handle;
+ set up HW for send
+
+The stack has already inserted the appropriate IPsec headers in the
+packet data, the offload just needs to do the encryption and fix up the
+header values.
+
+
+When a packet is received and the HW has indicated that it offloaded a
+decryption, the driver needs to add a reference to the decoded SA into
+the packet's skb. At this point the data should be decrypted but the
+IPsec headers are still in the packet data; they are removed later up
+the stack in xfrm_input().
+
+ find and hold the SA that was used to the Rx skb
+ get spi, protocol, and destination IP from packet headers
+ xs = find xs from (spi, protocol, dest_IP)
+ xfrm_state_hold(xs);
+
+ store the state information into the skb
+ skb->sp = secpath_dup(skb->sp);
+ skb->sp->xvec[skb->sp->len++] = xs;
+ skb->sp->olen++;
+
+ indicate the success and/or error status of the offload
+ xo = xfrm_offload(skb);
+ xo->flags = CRYPTO_DONE;
+ xo->status = crypto_status;
+
+ hand the packet to napi_gro_receive() as usual
+
+
+When the SA is removed by the user, the driver's xdo_dev_state_delete()
+is asked to disable the offload. Later, xdo_dev_state_free() is called
+from a garbage collection routine after all reference counts to the state
+have been removed and any remaining resources can be cleared for the
+offload state. How these are used by the driver will depend on specific
+hardware needs.
+
+As a netdev is set to DOWN the XFRM stack's netdev listener will call
+xdo_dev_state_delete() and xdo_dev_state_free() on any remaining offloaded
+states.
+
+
--
2.14.1
^ permalink raw reply related
* Re: [RFT/RFC net-next 0/2] net: dsa: Plug in PHYLINK support
From: Andrew Lunn @ 2017-12-15 12:48 UTC (permalink / raw)
To: Russell King - ARM Linux
Cc: Florian Fainelli, netdev, sean.wang, john, kernel, privat,
Woojung.Huh, vivien.didelot
In-Reply-To: <20171215120831.GS10595@n2100.armlinux.org.uk>
> 1. s/WARN_ON(!lockdep_rtnl_is_held())/ASSERT_RTNL()/ in phylink.c -
> probably wouldn't have been noticed if it wasn't for the lockdep
> splat with DSA's interrupt handling during boot that's been there
> since -rc1. (Andrew mentioned that it's known, so I haven't
> reported that.)
Hi Russell
https://lkml.org/lkml/2017/12/2/260
This should fix that splat. I hope it will get picked up at some
point. It is probably getting on time to repost it.
Andrew
^ permalink raw reply
* Re: [PATCH bpf-next 0/5] nfp: bpf: adjust head support
From: Daniel Borkmann @ 2017-12-15 13:21 UTC (permalink / raw)
To: Jakub Kicinski, netdev; +Cc: oss-drivers, alexei.starovoitov
In-Reply-To: <20171215052919.18343-1-jakub.kicinski@netronome.com>
On 12/15/2017 06:29 AM, Jakub Kicinski wrote:
> Hi!
>
> This small set adds support for bpf_xdp_adjust_head() to the offload.
> Since we have access to unmodified BPF bytecode translating calls is
> pretty trivial. First part of the series adds handling of BPF
> capabilities included in the FW in TLV format. The last two patches
> add adjust head support in the nfp verifier and jit, and a small
> optimization in case we can guarantee the constant adjustment
> will always meet adjustment constaints.
Series applied to bpf-next, thanks Jakub!
^ permalink raw reply
* [patch net] mlxsw: spectrum: Disable MAC learning for ovs port
From: Jiri Pirko @ 2017-12-15 13:26 UTC (permalink / raw)
To: netdev; +Cc: davem, yuvalm, idosch, mlxsw
From: Yuval Mintz <yuvalm@mellanox.com>
Learning is currently enabled for ports which are OVS slaves -
even though OVS doesn't need this indication.
Since we're not associating a fid with the port, HW would continuously
notify driver of learned [& aged] MACs which would be logged as errors.
Fixes: 2b94e58df58c ("mlxsw: spectrum: Allow ports to work under OVS master")
Signed-off-by: Yuval Mintz <yuvalm@mellanox.com>
Reviewed-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
---
drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
index 2d0897b..9bd8d28 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
@@ -4300,6 +4300,7 @@ static int mlxsw_sp_port_stp_set(struct mlxsw_sp_port *mlxsw_sp_port,
static int mlxsw_sp_port_ovs_join(struct mlxsw_sp_port *mlxsw_sp_port)
{
+ u16 vid = 1;
int err;
err = mlxsw_sp_port_vp_mode_set(mlxsw_sp_port, true);
@@ -4312,8 +4313,19 @@ static int mlxsw_sp_port_ovs_join(struct mlxsw_sp_port *mlxsw_sp_port)
true, false);
if (err)
goto err_port_vlan_set;
+
+ for (; vid <= VLAN_N_VID - 1; vid++) {
+ err = mlxsw_sp_port_vid_learning_set(mlxsw_sp_port,
+ vid, false);
+ if (err)
+ goto err_vid_learning_set;
+ }
+
return 0;
+err_vid_learning_set:
+ for (vid--; vid >= 1; vid--)
+ mlxsw_sp_port_vid_learning_set(mlxsw_sp_port, vid, true);
err_port_vlan_set:
mlxsw_sp_port_stp_set(mlxsw_sp_port, false);
err_port_stp_set:
@@ -4323,6 +4335,12 @@ static int mlxsw_sp_port_ovs_join(struct mlxsw_sp_port *mlxsw_sp_port)
static void mlxsw_sp_port_ovs_leave(struct mlxsw_sp_port *mlxsw_sp_port)
{
+ u16 vid;
+
+ for (vid = VLAN_N_VID - 1; vid >= 1; vid--)
+ mlxsw_sp_port_vid_learning_set(mlxsw_sp_port,
+ vid, true);
+
mlxsw_sp_port_vlan_set(mlxsw_sp_port, 2, VLAN_N_VID - 1,
false, false);
mlxsw_sp_port_stp_set(mlxsw_sp_port, false);
--
2.9.5
^ permalink raw reply related
* [PATCH net-next] net: dsa: lan9303: lan9303_csr_reg_wait cleanups
From: Egil Hjelmeland @ 2017-12-15 13:28 UTC (permalink / raw)
To: andrew, vivien.didelot, f.fainelli, netdev, linux-kernel; +Cc: Egil Hjelmeland
Non-functional cleanups in lan9303_csr_reg_wait():
- Change type of param 'mask' from int to u32.
- Remove param 'value' (will probably never be used)
- Reduced retries from 1000 to 25, consistent with lan9303_read_wait.
- Corrected comments
Signed-off-by: Egil Hjelmeland <privat@egil-hjelmeland.no>
---
drivers/net/dsa/lan9303-core.c | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/drivers/net/dsa/lan9303-core.c b/drivers/net/dsa/lan9303-core.c
index f412aad58253..209882075e3b 100644
--- a/drivers/net/dsa/lan9303-core.c
+++ b/drivers/net/dsa/lan9303-core.c
@@ -249,7 +249,7 @@ static int lan9303_read(struct regmap *regmap, unsigned int offset, u32 *reg)
return -EIO;
}
-/* Wait a while until mask & reg == value. Otherwise return timeout. */
+/* Wait a while until mask & reg == 0. Otherwise return timeout. */
static int lan9303_read_wait(struct lan9303 *chip, int offset, u32 mask)
{
int i;
@@ -541,20 +541,20 @@ lan9303_alr_cache_find_mac(struct lan9303 *chip, const u8 *mac_addr)
return NULL;
}
-/* Wait a while until mask & reg == value. Otherwise return timeout. */
-static int lan9303_csr_reg_wait(struct lan9303 *chip, int regno,
- int mask, char value)
+/* Wait a while until mask & reg == 0. Otherwise return timeout. */
+static int lan9303_csr_reg_wait(struct lan9303 *chip, int regno, u32 mask)
{
int i;
- for (i = 0; i < 0x1000; i++) {
+ for (i = 0; i < 25; i++) {
u32 reg;
lan9303_read_switch_reg(chip, regno, ®);
- if ((reg & mask) == value)
+ if (!(reg & mask))
return 0;
usleep_range(1000, 2000);
}
+
return -ETIMEDOUT;
}
@@ -564,8 +564,7 @@ static int lan9303_alr_make_entry_raw(struct lan9303 *chip, u32 dat0, u32 dat1)
lan9303_write_switch_reg(chip, LAN9303_SWE_ALR_WR_DAT_1, dat1);
lan9303_write_switch_reg(chip, LAN9303_SWE_ALR_CMD,
LAN9303_ALR_CMD_MAKE_ENTRY);
- lan9303_csr_reg_wait(chip, LAN9303_SWE_ALR_CMD_STS, ALR_STS_MAKE_PEND,
- 0);
+ lan9303_csr_reg_wait(chip, LAN9303_SWE_ALR_CMD_STS, ALR_STS_MAKE_PEND);
lan9303_write_switch_reg(chip, LAN9303_SWE_ALR_CMD, 0);
return 0;
--
2.14.1
^ permalink raw reply related
* Re: [PATCH bpf] xdp: linearize skb in netif_receive_generic_xdp()
From: Daniel Borkmann @ 2017-12-15 13:39 UTC (permalink / raw)
To: Song Liu, netdev; +Cc: kernel-team, Alexei Starovoitov
In-Reply-To: <20171215011756.573758-1-songliubraving@fb.com>
On 12/15/2017 02:17 AM, Song Liu wrote:
> In netif_receive_generic_xdp(), it is necessary to linearize all
> nonlinear skb. However, in current implementation, skb with
> troom <= 0 are not linearized. This patch fixes this by calling
> skb_linearize() for all nonlinear skb.
>
> Fixes: de8f3a83b0a0 ("bpf: add meta pointer for direct access")
> Signed-off-by: Song Liu <songliubraving@fb.com>
> Acked-by: Martin KaFai Lau <kafai@fb.com>
> Cc: Daniel Borkmann <daniel@iogearbox.net>
> Cc: Alexei Starovoitov <ast@kernel.org>
Agree, applied to bpf, thanks Song!
^ permalink raw reply
* Re: [PATCH v2 iproute2 1/1] ss: add missing path MTU parameter
From: Roman Mashak @ 2017-12-15 13:58 UTC (permalink / raw)
To: Stefano Brivio; +Cc: stephen, netdev, jhs
In-Reply-To: <20171215094515.386f8e6f@elisabeth>
Stefano Brivio <sbrivio@redhat.com> writes:
> On Thu, 14 Dec 2017 14:59:11 -0500
> Roman Mashak <mrv@mojatatu.com> wrote:
>
>> @@ -1959,6 +1960,8 @@ static void tcp_stats_print(struct tcpstat *s)
>>
>> if (s->mss)
>> printf(" mss:%d", s->mss);
>> + if (s->pmtu)
>> + printf(" pmtu:%u", s->pmtu);
>
> You'll simply need to change this to out() now, as this print will be
> buffered.
Oh I see why it does not apply, I'll resubmit. Thanks Stefano.
^ permalink raw reply
* Re: [PATCH 2/4] sctp: Add ip option support
From: Paul Moore @ 2017-12-15 14:02 UTC (permalink / raw)
To: Marcelo Ricardo Leitner
Cc: Richard Haines, selinux, netdev, linux-sctp,
linux-security-module, Vlad Yasevich, nhorman, Stephen Smalley,
Eric Paris
In-Reply-To: <20171214210422.GQ3532@localhost.localdomain>
On December 14, 2017 4:04:28 PM Marcelo Ricardo Leitner
<marcelo.leitner@gmail.com> wrote:
> On Tue, Dec 12, 2017 at 05:24:46PM -0500, Paul Moore wrote:
>> On Tue, Dec 12, 2017 at 4:56 PM, Marcelo Ricardo Leitner
>> <marcelo.leitner@gmail.com> wrote:
>> > On Tue, Dec 12, 2017 at 04:33:03PM -0500, Paul Moore wrote:
>> >> On Tue, Dec 12, 2017 at 11:08 AM, Marcelo Ricardo Leitner
>> >> <marcelo.leitner@gmail.com> wrote:
>> >> > Hi Richard,
>> >> >
>> >> > On Mon, Nov 27, 2017 at 07:31:21PM +0000, Richard Haines wrote:
>> >> > ...
>> >> >> --- a/net/sctp/socket.c
>> >> >> +++ b/net/sctp/socket.c
>> >> >> @@ -3123,8 +3123,10 @@ static int sctp_setsockopt_maxseg(struct sock
>> *sk, char __user *optval, unsigned
>> >> >>
>> >> >> if (asoc) {
>> >> >> if (val == 0) {
>> >> >> + struct sctp_af *af = sp->pf->af;
>> >> >> val = asoc->pathmtu;
>> >> >> - val -= sp->pf->af->net_header_len;
>> >> >> + val -= af->ip_options_len(asoc->base.sk);
>> >> >> + val -= af->net_header_len;
>> >> >> val -= sizeof(struct sctphdr) +
>> >> >> sizeof(struct sctp_data_chunk);
>> >> >> }
>> >> >
>> >> > Right below here there is a call to sctp_frag_point(). That function
>> >> > also needs this tweak.
>> >> >
>> >> > Yes, we should simplify all these calculations. I have a patch to use
>> >> > sctp_frag_point on where it is currently recalculating it on
>> >> > sctp_datamsg_from_user(), but probably should include other places as
>> >> > well.
>> >>
>> >> FYI: Richard let me know he is occupied with another project at the
>> >> moment and likely won't be able to do another respin until next week
>> >> at the earliest.
>> >
>> > Okay, thanks. I can do a follow-up patch if it helps.
>>
>> I'll leave that up to you, I think your comments are pretty
>> straightforward and should be easy for Richard to incorporate, and
>> there is a lot to be said for including the fix in the original patch,
>> but if you would prefer to send a separate patch I think that's fine
>> too.
>
> This patchset conflicts with the stream schedulers patchset (on
> sctp.h) and will also conflict with the stream interleaving patchsets
> from Xin (other files).
>
> I rebased the patchset upon current crypto tree but the last patchset
> on stream interleaving is still to be accepted via net-next.
>
> I'm unsure on how to proceed here. Please advise.
>
> Thanks,
> Marcelo
I still believe the right course of action is to merge this via the SELinux
tree (based on Linus' tree). Due to the nature of SELinux we often have to
deal with conflicts like this; I haven't seen the conflicts your talking
about (I'm currently traveling with limited access) but Linus should be
able to handle the trivial fixes, if it is more complex we can provide
guidance about how to resolve it.
^ permalink raw reply
* Re: [PATCH v2 net-next 1/3] net: dsa: mediatek: add VLAN support for MT7530
From: kbuild test robot @ 2017-12-15 14:13 UTC (permalink / raw)
To: sean.wang
Cc: kbuild-all, davem, andrew, f.fainelli, vivien.didelot, netdev,
linux-kernel, linux-mediatek, Sean Wang
In-Reply-To: <72a0a9f2748193bc02fed5e74c343aa5397348b7.1513136754.git.sean.wang@mediatek.com>
[-- Attachment #1: Type: text/plain, Size: 8625 bytes --]
Hi Sean,
I love your patch! Yet something to improve:
[auto build test ERROR on net-next/master]
url: https://github.com/0day-ci/linux/commits/sean-wang-mediatek-com/add-VLAN-support-to-DSA-MT7530/20171215-214450
config: i386-randconfig-x019-201750 (attached as .config)
compiler: gcc-7 (Debian 7.2.0-12) 7.2.1 20171025
reproduce:
# save the attached .config to linux build tree
make ARCH=i386
All errors (new ones prefixed by >>):
drivers/net/dsa/mt7530.c: In function 'mt7530_port_vlan_add':
drivers/net/dsa/mt7530.c:1131:6: warning: unused variable 'ret' [-Wunused-variable]
int ret;
^~~
drivers/net/dsa/mt7530.c: At top level:
>> drivers/net/dsa/mt7530.c:1324:23: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
.port_vlan_prepare = mt7530_port_vlan_prepare,
^~~~~~~~~~~~~~~~~~~~~~~~
drivers/net/dsa/mt7530.c:1324:23: note: (near initialization for 'mt7530_switch_ops.port_vlan_prepare')
drivers/net/dsa/mt7530.c:1325:20: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
.port_vlan_add = mt7530_port_vlan_add,
^~~~~~~~~~~~~~~~~~~~
drivers/net/dsa/mt7530.c:1325:20: note: (near initialization for 'mt7530_switch_ops.port_vlan_add')
cc1: some warnings being treated as errors
vim +1324 drivers/net/dsa/mt7530.c
1121
1122 static void
1123 mt7530_port_vlan_add(struct dsa_switch *ds, int port,
1124 const struct switchdev_obj_port_vlan *vlan,
1125 struct switchdev_trans *trans)
1126 {
1127 bool untagged = vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED;
1128 bool pvid = vlan->flags & BRIDGE_VLAN_INFO_PVID;
1129 struct mt7530_hw_vlan_entry new_entry;
1130 struct mt7530_priv *priv = ds->priv;
> 1131 int ret;
1132 u16 vid;
1133
1134 /* The port is kept as VLAN-unaware if bridge with vlan_filtering not
1135 * being set.
1136 */
1137 if (!priv->ports[port].vlan_filtering)
1138 return;
1139
1140 mutex_lock(&priv->reg_mutex);
1141
1142 for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid) {
1143 mt7530_hw_vlan_entry_init(&new_entry, port, untagged);
1144 mt7530_hw_vlan_update(priv, vid, &new_entry,
1145 mt7530_hw_vlan_add);
1146 }
1147
1148 if (pvid) {
1149 mt7530_rmw(priv, MT7530_PPBV1_P(port), G0_PORT_VID_MASK,
1150 G0_PORT_VID(vlan->vid_end));
1151 priv->ports[port].pvid = vlan->vid_end;
1152 }
1153
1154 mutex_unlock(&priv->reg_mutex);
1155 }
1156
1157 static int
1158 mt7530_port_vlan_del(struct dsa_switch *ds, int port,
1159 const struct switchdev_obj_port_vlan *vlan)
1160 {
1161 struct mt7530_hw_vlan_entry target_entry;
1162 struct mt7530_priv *priv = ds->priv;
1163 u16 vid, pvid;
1164
1165 /* The port is kept as VLAN-unaware if bridge with vlan_filtering not
1166 * being set.
1167 */
1168 if (!priv->ports[port].vlan_filtering)
1169 return 0;
1170
1171 mutex_lock(&priv->reg_mutex);
1172
1173 pvid = priv->ports[port].pvid;
1174 for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid) {
1175 mt7530_hw_vlan_entry_init(&target_entry, port, 0);
1176 mt7530_hw_vlan_update(priv, vid, &target_entry,
1177 mt7530_hw_vlan_del);
1178
1179 /* PVID is being restored to the default whenever the PVID port
1180 * is being removed from the VLAN.
1181 */
1182 if (pvid == vid)
1183 pvid = G0_PORT_VID_DEF;
1184 }
1185
1186 mt7530_rmw(priv, MT7530_PPBV1_P(port), G0_PORT_VID_MASK, pvid);
1187 priv->ports[port].pvid = pvid;
1188
1189 mutex_unlock(&priv->reg_mutex);
1190
1191 return 0;
1192 }
1193
1194 static enum dsa_tag_protocol
1195 mtk_get_tag_protocol(struct dsa_switch *ds, int port)
1196 {
1197 struct mt7530_priv *priv = ds->priv;
1198
1199 if (port != MT7530_CPU_PORT) {
1200 dev_warn(priv->dev,
1201 "port not matched with tagging CPU port\n");
1202 return DSA_TAG_PROTO_NONE;
1203 } else {
1204 return DSA_TAG_PROTO_MTK;
1205 }
1206 }
1207
1208 static int
1209 mt7530_setup(struct dsa_switch *ds)
1210 {
1211 struct mt7530_priv *priv = ds->priv;
1212 int ret, i;
1213 u32 id, val;
1214 struct device_node *dn;
1215 struct mt7530_dummy_poll p;
1216
1217 /* The parent node of master netdev which holds the common system
1218 * controller also is the container for two GMACs nodes representing
1219 * as two netdev instances.
1220 */
1221 dn = ds->ports[MT7530_CPU_PORT].master->dev.of_node->parent;
1222 priv->ethernet = syscon_node_to_regmap(dn);
1223 if (IS_ERR(priv->ethernet))
1224 return PTR_ERR(priv->ethernet);
1225
1226 regulator_set_voltage(priv->core_pwr, 1000000, 1000000);
1227 ret = regulator_enable(priv->core_pwr);
1228 if (ret < 0) {
1229 dev_err(priv->dev,
1230 "Failed to enable core power: %d\n", ret);
1231 return ret;
1232 }
1233
1234 regulator_set_voltage(priv->io_pwr, 3300000, 3300000);
1235 ret = regulator_enable(priv->io_pwr);
1236 if (ret < 0) {
1237 dev_err(priv->dev, "Failed to enable io pwr: %d\n",
1238 ret);
1239 return ret;
1240 }
1241
1242 /* Reset whole chip through gpio pin or memory-mapped registers for
1243 * different type of hardware
1244 */
1245 if (priv->mcm) {
1246 reset_control_assert(priv->rstc);
1247 usleep_range(1000, 1100);
1248 reset_control_deassert(priv->rstc);
1249 } else {
1250 gpiod_set_value_cansleep(priv->reset, 0);
1251 usleep_range(1000, 1100);
1252 gpiod_set_value_cansleep(priv->reset, 1);
1253 }
1254
1255 /* Waiting for MT7530 got to stable */
1256 INIT_MT7530_DUMMY_POLL(&p, priv, MT7530_HWTRAP);
1257 ret = readx_poll_timeout(_mt7530_read, &p, val, val != 0,
1258 20, 1000000);
1259 if (ret < 0) {
1260 dev_err(priv->dev, "reset timeout\n");
1261 return ret;
1262 }
1263
1264 id = mt7530_read(priv, MT7530_CREV);
1265 id >>= CHIP_NAME_SHIFT;
1266 if (id != MT7530_ID) {
1267 dev_err(priv->dev, "chip %x can't be supported\n", id);
1268 return -ENODEV;
1269 }
1270
1271 /* Reset the switch through internal reset */
1272 mt7530_write(priv, MT7530_SYS_CTRL,
1273 SYS_CTRL_PHY_RST | SYS_CTRL_SW_RST |
1274 SYS_CTRL_REG_RST);
1275
1276 /* Enable Port 6 only; P5 as GMAC5 which currently is not supported */
1277 val = mt7530_read(priv, MT7530_MHWTRAP);
1278 val &= ~MHWTRAP_P6_DIS & ~MHWTRAP_PHY_ACCESS;
1279 val |= MHWTRAP_MANUAL;
1280 mt7530_write(priv, MT7530_MHWTRAP, val);
1281
1282 /* Enable and reset MIB counters */
1283 mt7530_mib_reset(ds);
1284
1285 mt7530_clear(priv, MT7530_MFC, UNU_FFP_MASK);
1286
1287 for (i = 0; i < MT7530_NUM_PORTS; i++) {
1288 /* Disable forwarding by default on all ports */
1289 mt7530_rmw(priv, MT7530_PCR_P(i), PCR_MATRIX_MASK,
1290 PCR_MATRIX_CLR);
1291
1292 if (dsa_is_cpu_port(ds, i))
1293 mt7530_cpu_port_enable(priv, i);
1294 else
1295 mt7530_port_disable(ds, i, NULL);
1296 }
1297
1298 /* Flush the FDB table */
1299 ret = mt7530_fdb_cmd(priv, MT7530_FDB_FLUSH, 0);
1300 if (ret < 0)
1301 return ret;
1302
1303 return 0;
1304 }
1305
1306 static const struct dsa_switch_ops mt7530_switch_ops = {
1307 .get_tag_protocol = mtk_get_tag_protocol,
1308 .setup = mt7530_setup,
1309 .get_strings = mt7530_get_strings,
1310 .phy_read = mt7530_phy_read,
1311 .phy_write = mt7530_phy_write,
1312 .get_ethtool_stats = mt7530_get_ethtool_stats,
1313 .get_sset_count = mt7530_get_sset_count,
1314 .adjust_link = mt7530_adjust_link,
1315 .port_enable = mt7530_port_enable,
1316 .port_disable = mt7530_port_disable,
1317 .port_stp_state_set = mt7530_stp_state_set,
1318 .port_bridge_join = mt7530_port_bridge_join,
1319 .port_bridge_leave = mt7530_port_bridge_leave,
1320 .port_fdb_add = mt7530_port_fdb_add,
1321 .port_fdb_del = mt7530_port_fdb_del,
1322 .port_fdb_dump = mt7530_port_fdb_dump,
1323 .port_vlan_filtering = mt7530_port_vlan_filtering,
> 1324 .port_vlan_prepare = mt7530_port_vlan_prepare,
1325 .port_vlan_add = mt7530_port_vlan_add,
1326 .port_vlan_del = mt7530_port_vlan_del,
1327 };
1328
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 33639 bytes --]
^ permalink raw reply
* Re: [PATCH net-next 0/2] nfp: fix rtsym and XDP register handling in debug dump
From: Simon Horman @ 2017-12-15 14:18 UTC (permalink / raw)
To: David Miller, Jakub Kicinski; +Cc: netdev, oss-drivers, Carl Heymann
In-Reply-To: <20171214095026.11665-1-simon.horman@netronome.com>
On Thu, Dec 14, 2017 at 10:50:24AM +0100, Simon Horman wrote:
> Hi,
>
> this series resolves two problems in the recently added debug dump facility.
>
> * Correctly handle reading absolute rtysms
> * Correctly handle special-case PB register reads
>
> These fixes are for code only present in net-next.
Hi Dave,
It seems that I made a thinko in the title of the cover letter. s/XDP/XPB/
These changes do not relate to XDP.
> Carl Heymann (2):
> nfp: fix absolute rtsym handling in debug dump
> nfp: fix XPB register reads in debug dump
>
> .../net/ethernet/netronome/nfp/nfp_net_debugdump.c | 57 +++++++++++++++-------
> 1 file changed, 39 insertions(+), 18 deletions(-)
>
> --
> 2.11.0
>
^ permalink raw reply
* [PATCH v3 iproute2 1/1] ss: add missing path MTU parameter
From: Roman Mashak @ 2017-12-15 14:27 UTC (permalink / raw)
To: stephen; +Cc: netdev, jhs, Roman Mashak
v3:
Rebase and use out() instead of printf().
v2:
Print the path MTU immediately after the MSS, as it is easier to parse
for humans (suggested by Neal Cardwell).
Signed-off-by: Roman Mashak <mrv@mojatatu.com>
---
man/man8/ss.8 | 4 ++++
misc/ss.c | 4 ++++
2 files changed, 8 insertions(+)
diff --git a/man/man8/ss.8 b/man/man8/ss.8
index 6d06383..0d52673 100644
--- a/man/man8/ss.8
+++ b/man/man8/ss.8
@@ -184,6 +184,10 @@ max segment size
congestion window size
.P
.TP
+.B pmtu:<pmtu>
+path MTU value
+.P
+.TP
.B ssthresh:<ssthresh>
tcp congestion window slow start threshold
.P
diff --git a/misc/ss.c b/misc/ss.c
index 9d21ed7..1abf43d 100644
--- a/misc/ss.c
+++ b/misc/ss.c
@@ -790,6 +790,7 @@ struct tcpstat {
int mss;
int rcv_mss;
int advmss;
+ unsigned int pmtu;
unsigned int cwnd;
unsigned int lastsnd;
unsigned int lastrcv;
@@ -2360,6 +2361,8 @@ static void tcp_stats_print(struct tcpstat *s)
if (s->mss)
out(" mss:%d", s->mss);
+ if (s->pmtu)
+ out(" pmtu:%u", s->pmtu);
if (s->rcv_mss)
out(" rcvmss:%d", s->rcv_mss);
if (s->advmss)
@@ -2707,6 +2710,7 @@ static void tcp_show_info(const struct nlmsghdr *nlh, struct inet_diag_msg *r,
s.reordering = info->tcpi_reordering;
s.rcv_ssthresh = info->tcpi_rcv_ssthresh;
s.cwnd = info->tcpi_snd_cwnd;
+ s.pmtu = info->tcpi_pmtu;
if (info->tcpi_snd_ssthresh < 0xFFFF)
s.ssthresh = info->tcpi_snd_ssthresh;
--
2.7.4
^ permalink raw reply related
* [PATCH] net: qcom/emac: Reduce timeout for mdio read/write
From: Hemanth Puranik @ 2017-12-15 14:35 UTC (permalink / raw)
To: netdev, linux-kernel; +Cc: Timur Tabi, Hemanth Puranik
Currently mdio read/write takes around ~115us as the timeout
between status check is set to 100us.
By reducing the timeout to 1us mdio read/write takes ~15us to
complete. This improves the link up event response.
Signed-off-by: Hemanth Puranik <hpuranik@codeaurora.org>
---
drivers/net/ethernet/qualcomm/emac/emac-phy.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/qualcomm/emac/emac-phy.c b/drivers/net/ethernet/qualcomm/emac/emac-phy.c
index 18461fc..53dbf1e 100644
--- a/drivers/net/ethernet/qualcomm/emac/emac-phy.c
+++ b/drivers/net/ethernet/qualcomm/emac/emac-phy.c
@@ -47,6 +47,7 @@
#define MDIO_CLK_25_28 7
#define MDIO_WAIT_TIMES 1000
+#define MDIO_STATUS_DELAY_TIME 1
static int emac_mdio_read(struct mii_bus *bus, int addr, int regnum)
{
@@ -65,7 +66,7 @@ static int emac_mdio_read(struct mii_bus *bus, int addr, int regnum)
if (readl_poll_timeout(adpt->base + EMAC_MDIO_CTRL, reg,
!(reg & (MDIO_START | MDIO_BUSY)),
- 100, MDIO_WAIT_TIMES * 100))
+ MDIO_STATUS_DELAY_TIME, MDIO_WAIT_TIMES * 100))
return -EIO;
return (reg >> MDIO_DATA_SHFT) & MDIO_DATA_BMSK;
@@ -88,8 +89,8 @@ static int emac_mdio_write(struct mii_bus *bus, int addr, int regnum, u16 val)
writel(reg, adpt->base + EMAC_MDIO_CTRL);
if (readl_poll_timeout(adpt->base + EMAC_MDIO_CTRL, reg,
- !(reg & (MDIO_START | MDIO_BUSY)), 100,
- MDIO_WAIT_TIMES * 100))
+ !(reg & (MDIO_START | MDIO_BUSY)),
+ MDIO_STATUS_DELAY_TIME, MDIO_WAIT_TIMES * 100))
return -EIO;
return 0;
--
Qualcomm Datacenter Technologies as an affiliate of Qualcomm Technologies, Inc.
Qualcomm Technologies, Inc. is a member of the
Code Aurora Forum, a Linux Foundation Collaborative Project.
^ permalink raw reply related
* Re: [PATCH net-next] net: dsa: lan9303: lan9303_csr_reg_wait cleanups
From: Vivien Didelot @ 2017-12-15 14:49 UTC (permalink / raw)
To: Egil Hjelmeland, andrew, f.fainelli, netdev, linux-kernel; +Cc: Egil Hjelmeland
In-Reply-To: <20171215132859.4553-1-privat@egil-hjelmeland.no>
Hi Egil,
Egil Hjelmeland <privat@egil-hjelmeland.no> writes:
> Non-functional cleanups in lan9303_csr_reg_wait():
> - Change type of param 'mask' from int to u32.
> - Remove param 'value' (will probably never be used)
> - Reduced retries from 1000 to 25, consistent with lan9303_read_wait.
> - Corrected comments
>
> Signed-off-by: Egil Hjelmeland <privat@egil-hjelmeland.no>
> ---
> drivers/net/dsa/lan9303-core.c | 15 +++++++--------
> 1 file changed, 7 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/net/dsa/lan9303-core.c b/drivers/net/dsa/lan9303-core.c
> index f412aad58253..209882075e3b 100644
> --- a/drivers/net/dsa/lan9303-core.c
> +++ b/drivers/net/dsa/lan9303-core.c
> @@ -249,7 +249,7 @@ static int lan9303_read(struct regmap *regmap, unsigned int offset, u32 *reg)
> return -EIO;
> }
>
> -/* Wait a while until mask & reg == value. Otherwise return timeout. */
> +/* Wait a while until mask & reg == 0. Otherwise return timeout. */
I'd remove this comment completely. The related code below is quite
explicit and speaks for itself, no need for an extra comment IMO.
for (...)
if (!(mask & reg))
return 0;
return -ETIMEOUT;
> static int lan9303_read_wait(struct lan9303 *chip, int offset, u32 mask)
> {
> int i;
> @@ -541,20 +541,20 @@ lan9303_alr_cache_find_mac(struct lan9303 *chip, const u8 *mac_addr)
> return NULL;
> }
>
> -/* Wait a while until mask & reg == value. Otherwise return timeout. */
> -static int lan9303_csr_reg_wait(struct lan9303 *chip, int regno,
> - int mask, char value)
> +/* Wait a while until mask & reg == 0. Otherwise return timeout. */
Same here, no need to add some code in a comment.
> +static int lan9303_csr_reg_wait(struct lan9303 *chip, int regno, u32 mask)
> {
> int i;
>
> - for (i = 0; i < 0x1000; i++) {
> + for (i = 0; i < 25; i++) {
> u32 reg;
>
> lan9303_read_switch_reg(chip, regno, ®);
> - if ((reg & mask) == value)
> + if (!(reg & mask))
> return 0;
> usleep_range(1000, 2000);
> }
> +
> return -ETIMEDOUT;
> }
>
> @@ -564,8 +564,7 @@ static int lan9303_alr_make_entry_raw(struct lan9303 *chip, u32 dat0, u32 dat1)
> lan9303_write_switch_reg(chip, LAN9303_SWE_ALR_WR_DAT_1, dat1);
> lan9303_write_switch_reg(chip, LAN9303_SWE_ALR_CMD,
> LAN9303_ALR_CMD_MAKE_ENTRY);
> - lan9303_csr_reg_wait(chip, LAN9303_SWE_ALR_CMD_STS, ALR_STS_MAKE_PEND,
> - 0);
> + lan9303_csr_reg_wait(chip, LAN9303_SWE_ALR_CMD_STS, ALR_STS_MAKE_PEND);
> lan9303_write_switch_reg(chip, LAN9303_SWE_ALR_CMD, 0);
The rest of the patch makes sense.
Thanks,
Vivien
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox